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

Changeset 152

Show
Ignore:
Timestamp:
02/09/07 20:51:34 (2 years ago)
Author:
jk
Message:

#50

Files:

Legend:

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

    r151 r152  
    208208    qp = Ferret::QueryParser.new(:fields => ['title', 'content', 'description'], 
    209209                      :analyzer => Ferret::Analysis::WhiteSpaceAnalyzer.new) 
    210     # TODO '*' doesn't seem to work in 0.9 anymore - there's no .fields method 
    211     # either :-( 
    212     #qp.fields = i.reader.get_field_names.to_a 
    213     #qp.fields = ['title','content'] 
    214210    hits = i.search(qp.parse("title")) 
    215211    assert_equal 2, hits.total_hits 
     
    232228    hits.hits.each { |hit, score| count += 1 } 
    233229    assert_equal 3, count 
     230  end 
     231 
     232  def test_find_rebuilds_index 
     233    remove_index Content 
     234    contents_from_ferret = Content.find_by_contents('description:title') 
     235    assert_equal 1, contents_from_ferret.size 
     236  end 
     237 
     238  def test_multi_search_rebuilds_index 
     239    remove_index Content 
     240    contents_from_ferret = Content.multi_search('description:title') 
     241    assert_equal 1, contents_from_ferret.size 
     242  end 
     243 
     244  def test_multi_index_rebuilds_index 
     245    remove_index Content 
     246    i =  ActsAsFerret::MultiIndex.new([Content]) 
     247    assert File.exists?("#{Content.aaf_configuration[:index_dir]}/segments") 
     248    hits = i.search("description:title") 
     249    assert_equal 1, hits.total_hits, hits.inspect 
     250  end 
     251 
     252  def remove_index(clazz) 
     253    clazz.aaf_index.close # avoid io error when deleting the open index 
     254    FileUtils.rm_rf clazz.aaf_configuration[:index_dir] 
     255    assert !File.exists?("#{clazz.aaf_configuration[:index_dir]}/segments") 
    234256  end 
    235257 
  • trunk/demo/test/unit/shared_index1_test.rb

    r147 r152  
    2828  end 
    2929 
    30   def custom_query 
     30  def test_custom_query 
    3131    result = SharedIndex1.find_by_contents("name:first class_name:SharedIndex1") 
    3232    assert_equal 1, result.size 

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