mirror of
https://github.com/kaminari/kaminari.git
synced 2022-11-09 13:44:37 -05:00
Fix :num_pages options to keep backwards-compatible
This commit is contained in:
parent
baa38d4b4a
commit
1c58998201
2 changed files with 13 additions and 1 deletions
|
@ -14,7 +14,7 @@ module Kaminari
|
|||
def initialize(template, options) #:nodoc:
|
||||
#FIXME for compatibility. remove num_pages at some time in the future
|
||||
options[:total_pages] ||= options[:num_pages]
|
||||
options[:num_pages] ||= options[:total_pages]
|
||||
options[:total_pages] = options[:num_pages] if options[:num_pages].present?
|
||||
|
||||
@window_options = {}.tap do |h|
|
||||
h[:window] = options.delete(:window) || options.delete(:inner_window) || Kaminari.config.window
|
||||
|
|
|
@ -30,6 +30,18 @@ describe 'Kaminari::ActionViewExtension', :if => defined?(Rails) do
|
|||
end
|
||||
end
|
||||
|
||||
specify '#total_pages' do
|
||||
@users = User.page(1).per(1)
|
||||
result = helper.paginate @users, total_pages: 3, :params => {:controller => 'users', :action => 'index'}
|
||||
expect(result.scan('<span class="page">').count).to eq(2)
|
||||
end
|
||||
|
||||
specify '#total_pages legacy' do
|
||||
@users = User.page(1).per(1)
|
||||
result = helper.paginate @users, num_pages: 3, :params => {:controller => 'users', :action => 'index'}
|
||||
expect(result.scan('<span class="page">').count).to eq(2)
|
||||
end
|
||||
|
||||
describe '#link_to_previous_page' do
|
||||
before do
|
||||
60.times {|i| User.create! :name => "user#{i}"}
|
||||
|
|
Loading…
Reference in a new issue