1
0
Fork 0
mirror of https://github.com/kaminari/kaminari.git synced 2022-11-09 13:44:37 -05:00

Failing spec for AR4 + custom select + count

refs #409
This commit is contained in:
Akira Matsuda 2013-08-29 18:42:03 +09:00
parent e56f7d2c46
commit caa11f6626

View file

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