| | 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 | |
|---|