Changeset 86
- Timestamp:
- 08/30/06 21:51:20 (2 years ago)
- Files:
-
- trunk/demo/test/unit/comment_test.rb (modified) (2 diffs)
- trunk/demo/test/unit/content_test.rb (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/demo/test/unit/comment_test.rb
r82 r86 17 17 end 18 18 19 def test_reloadable20 assert ! Comment.reloadable?21 end19 #def test_reloadable 20 # assert ! Comment.reloadable? 21 #end 22 22 23 23 # tests the automatic building of an index when none exists … … 139 139 # fixed with Ferret 0.9.6 140 140 def test_stopwords_ferret_bug 141 i = Ferret::Index::Index.new( 142 :or_default => false, 143 :default_field => '*' 144 ) 145 d = Ferret::Document::Document.new 141 i = Ferret::I.new(:or_default => false, :default_field => '*' ) 142 d = Ferret::Document.new 146 143 d[:id] = '1' 147 144 d[:content] = 'Move or shake' 148 145 i << d 149 hits = i.search 'move nothere shake' 150 assert_equal 0,hits.size 151 hits = i.search 'move shake' 152 assert_equal 1,hits.size 153 hits = i.search 'move or shake' 154 assert_equal 1,hits.size 155 hits = i.search 'move and shake' 156 assert_equal 1,hits.size 146 hits = i.search 'move AND or AND shake' 147 assert_equal 1, hits.total_hits 148 hits = i.search 'move AND nothere AND shake' 149 assert_equal 0, hits.total_hits 150 hits = i.search 'move AND shake' 151 assert_equal 1, hits.total_hits 152 hits = i.search 'move OR shake' 153 assert_equal 1, hits.total_hits 154 155 hits = i.search 'move nothere' 156 assert_equal 0, hits.total_hits 157 157 end 158 158 trunk/demo/test/unit/content_test.rb
r78 r86 92 92 end 93 93 94 def test_sorting 95 sorting = [ Ferret::Search::SortField.new(:id, :reverse => true) ] 96 result = Content.find_by_contents('comment_count:2', :sort => sorting) 97 assert result.first.id > result.last.id 98 99 sorting = [ Ferret::Search::SortField.new(:id) ] 100 result = Content.find_by_contents('comment_count:2', :sort => sorting) 101 assert result.first.id < result.last.id 102 end 103 94 104 def test_multi_index 95 105 i = FerretMixin::Acts::ARFerret::MultiIndex.new([Content, Comment]) … … 175 185 assert_equal contents(:first).id, contents_from_ferret.first[:id].to_i 176 186 assert_equal @another_content.id, contents_from_ferret.last[:id].to_i 177 assert contents_from_ferret.first[:score] > contents_from_ferret.last[:score]187 assert contents_from_ferret.first[:score] >= contents_from_ferret.last[:score] 178 188 179 189 # give description field higher boost: … … 195 205 assert_equal contents(:first).id, contents_from_ferret.last.id 196 206 end 207 208 def test_default_and_queries 209 # multiple terms are ANDed by default... 210 contents_from_ferret = Content.find_by_contents('monkey description') 211 assert contents_from_ferret.empty? 212 # ...unless you connect them by OR 213 contents_from_ferret = Content.find_by_contents('monkey OR description') 214 assert_equal 1, contents_from_ferret.size 215 assert_equal contents(:first).id, contents_from_ferret.first.id 216 217 # multiple terms, each term has to occur in a document to be found, 218 # but they may occur in different fields 219 contents_from_ferret = Content.find_by_contents('useless title') 220 assert_equal 1, contents_from_ferret.size 221 assert_equal contents(:first).id, contents_from_ferret.first.id 222 end 197 223 198 224 def test_find_by_contents … … 231 257 assert contents_from_ferret.empty? 232 258 233 # multiple terms are ANDed by default...234 contents_from_ferret = Content.find_by_contents('monkey description')235 assert contents_from_ferret.empty?236 # ...unless you connect them by OR237 contents_from_ferret = Content.find_by_contents('monkey OR description')238 assert_equal 1, contents_from_ferret.size239 assert_equal contents(:first).id, contents_from_ferret.first.id240 241 # multiple terms, each term has to occur in a document to be found,242 # but they may occur in different fields243 contents_from_ferret = Content.find_by_contents('useless title')244 assert_equal 1, contents_from_ferret.size245 assert_equal contents(:first).id, contents_from_ferret.first.id246 259 247 260
