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

Changeset 290

Show
Ignore:
Timestamp:
12/16/07 20:27:53 (10 months ago)
Author:
jk
Message:

allow for per-model conditions in multi_search

Files:

Legend:

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

    r287 r290  
    497497    id = Content.find_with_ferret('title').first.id 
    498498    r = Content.find_with_ferret('title OR comment', { :multi => Comment, :limit => :all }, 
    499                                                      { :conditions => ["id != ?", id] }) 
     499                                                     { :conditions => { :content => ["id != ?", id] }}) 
    500500    assert_equal 59, r.size 
    501501    assert_equal 59, r.total_hits 
    502502 
    503503    r = Content.find_with_ferret('title OR comment', { :multi => Comment, :limit => 20 }, 
    504                                                      { :conditions => ["id != ?", id] }) 
     504                                                     { :conditions => { :content => ["id != ?", id] }}) 
    505505    assert_equal 20, r.size 
    506506    assert_equal 59, r.total_hits 
    507507 
     508    r = Content.find_with_ferret('title OR comment', { :multi => Comment, :limit => 20 }, 
     509                                                     { :conditions => { :comment => 'content is null', 
     510                                                                        :content => ["id != ?", id] }}) 
     511    assert_equal 20, r.size 
     512    assert_equal 29, r.total_hits 
     513 
    508514    r = Content.find_with_ferret('title OR comment', { :multi => Comment }, 
    509                                                      { :conditions => ["id != ?", id], :limit => 20 }) 
     515                                                     { :conditions => { :content => ["id != ?", id] }, :limit => 20 }) 
    510516    assert_equal 20, r.size 
    511517    assert_equal 59, r.total_hits 
     
    838844    id = Content.find_with_ferret('title').first.id 
    839845    r = Content.find_with_ferret 'title OR comment', { :page => 1, :per_page => 10, :multi => Comment },  
    840                                           { :conditions => ["id != ?", id], :order => 'id ASC' } 
     846                                          { :conditions => { :content => ["id != ?", id] }, :order => 'id ASC' } 
    841847    assert_equal 59, r.total_hits 
    842848    assert_equal 10, r.size 
     
    847853 
    848854    r = Content.find_with_ferret 'title OR comment', { :page => 6, :per_page => 10, :multi => Comment }, 
    849                                           { :conditions => [ "id != ?", id ], :order => 'id ASC' } 
     855                                          { :conditions => { :content => [ "id != ?", id ] }, :order => 'id ASC' } 
    850856    assert_equal 59, r.total_hits 
    851857    assert_equal 9, r.size 

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