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

Changeset 60

Show
Ignore:
Timestamp:
07/10/06 19:50:44 (2 years ago)
Author:
jk
Message:

fixing #4, #20, #24

Files:

Legend:

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

    r27 r60  
    77  # we use :store_class_name => true so that we can use  
    88  # the multi_search method to run queries across multiple 
    9   # models 
     9  # models (where each model has it's own index directory) 
    1010  acts_as_ferret :store_class_name => true 
    1111 
  • trunk/demo/test/fixtures/comments.yml

    r27 r60  
    1 # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html 
    21first: 
    32  id: 1 
  • trunk/demo/test/fixtures/contents.yml

    r30 r60  
    1 # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html 
    21first: 
    32  id: 1 
  • trunk/demo/test/unit/comment_test.rb

    r59 r60  
    33class CommentTest < Test::Unit::TestCase 
    44  fixtures :comments 
     5 
     6  def setup 
     7    Comment.rebuild_index 
     8  end 
    59 
    610  # Replace this with your real tests. 
  • trunk/demo/test/unit/content_test.rb

    r57 r60  
    142142    assert_equal @another_content.id, contents_from_ferret.last.id 
    143143     
     144    contents_from_ferret = Content.multi_search('title:title OR content:comment OR description:title', [Comment]) 
     145    assert_equal 5, contents_from_ferret.size 
     146    contents_from_ferret = Content.multi_search('*:title OR *:comment', [Comment]) 
     147    assert_equal 5, contents_from_ferret.size 
    144148    contents_from_ferret = Content.multi_search('title:(title OR comment) OR description:(title OR comment) OR content:(title OR comment)', [Comment]) 
    145149    assert_equal 5, contents_from_ferret.size 
    146     contents_from_ferret = Content.multi_search('title OR comment', [Comment]) 
    147     assert_equal 5, contents_from_ferret.size 
    148150  end 
    149151 
     
    151153    assert_equal 4, ContentBase.find(:all).size 
    152154     
    153     ['*:title', 'title:title OR description:title OR content:title', 'title'].each do |query| 
     155    [ 'title:title OR description:title OR content:title', 'title', '*:title'].each do |query| 
    154156      contents_from_ferret = Content.id_multi_search(query) 
    155       assert_equal 2, contents_from_ferret.size 
     157      assert_equal 2, contents_from_ferret.size, query 
    156158      assert_equal contents(:first).id, contents_from_ferret.first[:id].to_i 
    157159      assert_equal @another_content.id, contents_from_ferret.last[:id].to_i 
    158160    end 
    159161 
     162    ContentBase.rebuild_index 
     163    Comment.rebuild_index 
    160164    ['title OR comment', 'title:(title OR comment) OR description:(title OR comment) OR content:(title OR comment)'].each do |query| 
    161165      contents_from_ferret = Content.id_multi_search(query, [Comment]) 
    162       assert_equal 5, contents_from_ferret.size 
     166      assert_equal 5, contents_from_ferret.size, query 
    163167    end 
    164168  end 

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