diff --git a/spec/models/active_record/active_record_relation_methods_spec.rb b/spec/models/active_record/active_record_relation_methods_spec.rb index 27cc31b..f75dd6f 100644 --- a/spec/models/active_record/active_record_relation_methods_spec.rb +++ b/spec/models/active_record/active_record_relation_methods_spec.rb @@ -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 {