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

Changeset 111

Show
Ignore:
Timestamp:
11/15/06 19:10:26 (2 years ago)
Author:
jk
Message:

r2681@monsoon: jk | 2006-11-15 20:09:46 +0100
unit test for #52

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/demo/app/models/comment.rb

    r78 r111  
    1919 
    2020  # only index the named fields: 
    21   #acts_as_ferret :fields => ['author', 'content'
     21  #acts_as_ferret :fields => [:author, :content
    2222 
    2323  # you can override the default to_doc method  
     
    2828    doc = super 
    2929    # add a field containing the current time 
    30     doc['added'] = Time.now.to_i.to_s 
    31 #              Ferret::Document::Field::Store::YES,  
    32 #              Ferret::Document::Field::Index::UNTOKENIZED) 
     30    doc[:added] = Time.now.to_i.to_s 
    3331    return doc 
    3432  end 
  • trunk/demo/test/unit/comment_test.rb

    r102 r111  
    4646    assert_equal 1, comments_from_ferret.size 
    4747    assert_equal 2, comments_from_ferret.total_hits 
     48  end 
     49 
     50  def test_score 
     51    comments_from_ferret = Comment.find_by_contents('comment AND fixture', :num_docs => 1) 
     52    assert comments_from_ferret.first.ferret_score > 0 
    4853  end 
    4954 
     
    148153    hits = i.search 'move OR shake' 
    149154    assert_equal 1, hits.total_hits 
     155    hits = i.search '+move +the +shake' 
     156    assert_equal 1, hits.total_hits 
    150157 
    151158    hits = i.search 'move nothere' 
     
    153160  end 
    154161 
     162  # fails due to Ferret bug in 0.10.13, http://pastie.caboo.se/22886 
    155163  def test_stopwords 
    156164    comment = Comment.create( :author => 'john doe', :content => 'Move or shake' ) 
    157     ['move shake', 'Move shake', 'move Shake'].each do |q| 
     165    ['move shake', 'Move shake', 'move Shake', 'move or shake', 'move the shake'].each do |q| 
    158166      comments_from_ferret = Comment.find_by_contents(q) 
    159167      assert_equal comment, comments_from_ferret.first, "query #{q} failed" 
    160168    end 
    161  
    162     comments_from_ferret = Comment.find_by_contents('Move or shake') 
    163     assert_equal 1, comments_from_ferret.size 
    164     assert_equal comment, comments_from_ferret.first 
    165169    comment.destroy 
    166170  end 
  • trunk/demo/test/unit/content_test.rb

    r109 r111  
    274274    contents_from_ferret = Content.multi_search('title:title OR content:comment OR description:title', [Comment]) 
    275275    assert_equal 5, contents_from_ferret.size 
     276    contents_from_ferret = Content.multi_search('title:title OR content:comment OR description:title', [Comment], :limit => 2) 
     277    assert_equal 2, contents_from_ferret.size 
     278 
    276279    contents_from_ferret = Content.multi_search('*:title OR *:comment', Comment) 
    277280    assert_equal 5, contents_from_ferret.size 

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