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

Changeset 351 for trunk/demo

Show
Ignore:
Timestamp:
07/09/08 09:18:10 (4 months ago)
Author:
jk
Message:

fix sorting bug when using ferret sort along with pagination options

Files:

Legend:

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

    r320 r351  
    608608  end 
    609609 
     610  def test_pagination_with_ar_conditions_and_ferret_sort 
     611    more_contents 
     612 
     613    # r = Content.find_with_ferret 'title', { :page => 1, :per_page => 10, 
     614    #                                         :sort => Ferret::Search::SortField.new(:id, 
     615    #                                                                                :type => :integer, 
     616    #                                                                                :reverse => true ) },  
     617    #                                       { :conditions => "description != '0'" } 
     618    r = ActsAsFerret::find 'title', Content, { :page => 1, :per_page => 10, 
     619                                            :sort => Ferret::Search::SortField.new(:id, 
     620                                                                                   :type => :integer, 
     621                                                                                   :reverse => true ) },  
     622                                          { :conditions => "description != '29'" } 
     623    assert_equal 29, r.total_hits 
     624    assert_equal 10, r.size 
     625    assert_equal "28", r.first.description 
     626    assert_equal "19", r.last.description 
     627    assert_equal 1, r.current_page 
     628    assert_equal 3, r.page_count 
     629 
     630    r = Content.find_with_ferret 'title', { :page => 3, :per_page => 10 }, 
     631                                          { :conditions => "description != '0'", :order => 'title ASC' } 
     632    assert_equal 9, r.size 
     633    assert_equal 29, r.total_hits 
     634    assert_equal "21", r.first.description 
     635    assert_equal "29", r.last.description 
     636    assert_equal 3, r.current_page 
     637    assert_equal 3, r.page_count 
     638  end 
     639 
    610640  def test_pagination_with_more_conditions 
    611641    more_contents 

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