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

Stripping options for ActiveSupport::OrderedHash

This commit is contained in:
Ben Simpson 2012-09-18 14:04:54 -04:00
parent 8e0d22b0da
commit 35252fa201
2 changed files with 12 additions and 1 deletions

View file

@ -18,8 +18,12 @@ module Kaminari
# .group returns an OrderdHash that responds to #count
c = c.count(column_name, options)
if c.is_a?(ActiveSupport::OrderedHash)
c.count
else
c.respond_to?(:count) ? c.count(column_name, options) : c
end
end
end
end
end

View file

@ -35,6 +35,13 @@ if defined? ActiveRecord
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
-> {
@author.readers.by_read_count.page(1).total_count(:name, distinct: true)
}.should_not raise_exception
end
end
end
end
end