mirror of
https://github.com/kaminari/kaminari.git
synced 2022-11-09 13:44:37 -05:00
parent
b8757b7f0a
commit
01ec38a1ca
2 changed files with 5 additions and 1 deletions
|
@ -5,7 +5,7 @@ module Kaminari
|
|||
# Model.page(3).per(10)
|
||||
def per(num, max_per_page: nil)
|
||||
max_per_page ||= ((defined?(@_max_per_page) && @_max_per_page) || self.max_per_page)
|
||||
@_per = num || default_per_page
|
||||
@_per = (num || default_per_page).to_i
|
||||
if (n = num.to_i) < 0 || !(/^\d/ =~ num.to_s)
|
||||
self
|
||||
elsif n.zero?
|
||||
|
|
|
@ -84,6 +84,10 @@ if defined? ActiveRecord
|
|||
test "throw an exception when calculating total_count when the query includes column aliases used by a group-by clause" do
|
||||
assert_equal 3, Book.joins(authorships: :user).select("users.name as author_name").group('users.name').page(1).total_count
|
||||
end
|
||||
|
||||
test 'total_count is calculable with page 1 per "5" (the string)' do
|
||||
assert_equal 7, User.page(1).per('5').load.total_count
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue