To edit pages or tickets please login with username/password: aaf/aaf

Changeset 32

Show
Ignore:
Timestamp:
04/22/06 17:55:28 (2 years ago)
Author:
jk
Message:

test case for ticket #9

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/demo/test/unit/content_test.rb

    r30 r32  
    119119  end 
    120120 
     121  def test_find_id_by_contents 
     122    contents_from_ferret = Content.find_id_by_contents('title:title OR description:title') 
     123    assert_equal 2, contents_from_ferret.size 
     124    #puts "first (id=#{contents_from_ferret.first[:id]}): #{contents_from_ferret.first[:score]}" 
     125    #puts "last  (id=#{contents_from_ferret.last[:id]}): #{contents_from_ferret.last[:score]}" 
     126    assert_equal contents(:first).id, contents_from_ferret.first[:id].to_i  
     127    assert_equal @another_content.id, contents_from_ferret.last[:id].to_i 
     128    assert contents_from_ferret.first[:score] > contents_from_ferret.last[:score] 
     129      
     130    # give description field higher boost: 
     131    contents_from_ferret = Content.find_id_by_contents('title:title OR description:title^10') 
     132    assert_equal 2, contents_from_ferret.size 
     133    #puts "first (id=#{contents_from_ferret.first[:id]}): #{contents_from_ferret.first[:score]}" 
     134    #puts "last  (id=#{contents_from_ferret.last[:id]}): #{contents_from_ferret.last[:score]}" 
     135    assert_equal @another_content.id, contents_from_ferret.first[:id].to_i 
     136    assert_equal contents(:first).id, contents_from_ferret.last[:id].to_i  
     137    assert contents_from_ferret.first[:score] > contents_from_ferret.last[:score] 
     138      
     139  end 
     140   
     141  def test_find_by_contents_boost 
     142 
     143    # give description field higher boost: 
     144    contents_from_ferret = Content.find_by_contents('title:title OR description:title^10') 
     145    assert_equal 2, contents_from_ferret.size 
     146    assert_equal @another_content.id, contents_from_ferret.first.id 
     147    assert_equal contents(:first).id, contents_from_ferret.last.id  
     148  end 
     149   
    121150  def test_find_by_contents 
    122151 

To edit pages or tickets please login with username/password: aaf/aaf