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

Changeset 94

Show
Ignore:
Timestamp:
09/09/06 17:04:20 (2 years ago)
Author:
jk
Message:

r1106@monsoon: jk | 2006-09-09 17:11:39 +0200
more like this unit tests

Files:

Legend:

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

    r90 r94  
    100100  end 
    101101 
     102  def test_content_for_field_name 
     103    c = 'lorem ipsum dolor sit amet. lorem.' 
     104    @c1 = Content.new( :title => 'Content item 1',  
     105                       :description => c ) 
     106    assert_equal c, @c1.content_for_field_name(:description) 
     107  end 
     108 
     109  def test_document_number 
     110    c = 'lorem ipsum dolor sit amet. lorem.' 
     111    c1 = Content.new( :title => 'Content item 1',  
     112                       :description => c ) 
     113    c1.save 
     114    hits = Content.ferret_index.search('title:"Content item 1"') 
     115    assert_equal 1, hits.total_hits 
     116    expected_doc_num = hits.hits.first.doc 
     117    assert_equal c, Content.ferret_index[expected_doc_num][:description] 
     118    doc_num = c1.document_number 
     119    assert_equal expected_doc_num, doc_num 
     120    assert_equal c, Content.ferret_index[doc_num][:description] 
     121  end 
     122 
    102123  def test_more_like_this 
    103124    assert Content.find_by_contents('lorem ipsum').empty? 
     
    109130    @c2.save 
    110131    assert_equal 2, Content.find_by_contents('lorem ipsum').size 
    111     similar = @c1.more_like_this(:field_names => ['description'], :min_doc_freq => 1, :min_term_freq => 1) 
     132    similar = @c1.more_like_this(:field_names => [:description], :min_doc_freq => 1, :min_term_freq => 1) 
    112133    assert_equal 1, similar.size 
    113134    assert_equal @c2, similar.first 

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