Skip to content

Commit

Permalink
remember custom :count options in sub-relations
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Aug 3, 2011
1 parent 2b96781 commit 530ff2f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/will_paginate/active_record.rb
Expand Up @@ -109,6 +109,7 @@ def clone
other = super
other.current_page = current_page unless other.current_page
other.total_entries = nil if defined? @total_entries_queried
other.wp_count_options = @wp_count_options if defined? @wp_count_options
other
end

Expand Down
9 changes: 9 additions & 0 deletions spec/finders/active_record_spec.rb
Expand Up @@ -117,6 +117,15 @@
}.should run_queries(2)
end

it "remembers custom count options in sub-relations" do
topics = Topic.paginate :page => 1, :per_page => 3, :count => {:conditions => "title LIKE '%futurama%'"}
topics.total_entries.should == 1
topics.length.should == 3
lambda {
topics.order('id').total_entries.should == 1
}.should run_queries(1)
end

it "supports empty? method" do
topics = Topic.paginate :page => 1, :per_page => 3
lambda {
Expand Down

0 comments on commit 530ff2f

Please sign in to comment.