Commit f4699a8e484f86fdaab420746c7682b4321239d9
1 parent
e9b2ae4f
Exists in
master
and in
29 other branches
[search-improvements] If no results indexed, relevance must be zero
Showing
2 changed files
with
9 additions
and
0 deletions
Show diff stats
app/models/search_term.rb
test/unit/search_term_test.rb
... | ... | @@ -118,4 +118,12 @@ class SearchTermTest < ActiveSupport::TestCase |
118 | 118 | |
119 | 119 | assert st1.score > st2.score, "Less ratio results:total are not getting higher scores." |
120 | 120 | end |
121 | + | |
122 | + should 'consider relevance zero if no results indexed' do | |
123 | + st = SearchTerm.find_or_create('st', Environment.default) | |
124 | + SearchTermOccurrence.create!(:search_term => st, :total => 10, :indexed => 0) | |
125 | + SearchTerm.calculate_scores | |
126 | + st.reload | |
127 | + assert_equal 0, st.score | |
128 | + end | |
121 | 129 | end | ... | ... |