mirror of
https://github.com/kaminari/kaminari.git
synced 2022-11-09 13:44:37 -05:00
parent
e56f7d2c46
commit
caa11f6626
1 changed files with 10 additions and 0 deletions
|
@ -19,22 +19,32 @@ if defined? ActiveRecord
|
|||
@author.readers.by_read_count.page(1).total_count.should == @readers.size
|
||||
end
|
||||
end
|
||||
|
||||
context "when the scope use conditions on includes" do
|
||||
it "should keep includes and successfully count the results" do
|
||||
# Only @author and @author2 have books titled with the title00x partern
|
||||
User.includes(:books_authored).where("books.title LIKE 'title00%'").page(1).total_count.should == 2
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the Relation has custom select clause' do
|
||||
specify do
|
||||
lambda { User.select('*, 1 as one').page(1).total_count }.should_not raise_exception
|
||||
end
|
||||
end
|
||||
|
||||
context "when total_count receives options" do
|
||||
it "should return a distinct total count" do
|
||||
User.page(1).total_count(:name, :distinct => true).should == 4
|
||||
end
|
||||
end
|
||||
|
||||
context "when count receives options" do
|
||||
it "should return a distinct set by column" do
|
||||
User.page(1).count(:name, :distinct => true).should == 4
|
||||
end
|
||||
end
|
||||
|
||||
context "when the scope returns an ActiveSupport::OrderedHash" do
|
||||
it "should not throw exception by passing options to count" do
|
||||
lambda {
|
||||
|
|
Loading…
Reference in a new issue