Skip to content

Fix issue #284 #288

Closed
wants to merge 1 commit into from
View
3 lib/kaminari/helpers/paginator.rb
@@ -24,7 +24,7 @@ def initialize(template, options) #:nodoc:
@theme = @options[:theme] ? "#{@options[:theme]}/" : ''
@options[:current_page] = PageProxy.new @window_options.merge(@options), @options[:current_page], nil
#FIXME for compatibility. remove num_pages at some time in the future
- @options[:total_pages] ||= @options[:num_pages]
+ @options[:num_pages] = @options[:total_pages]
@last = nil
# initialize the output_buffer for Context
@output_buffer = ActionView::OutputBuffer.new
@@ -73,6 +73,7 @@ def #{tag}_tag
end
def to_s #:nodoc:
+ ActiveSupport::Deprecation.warn('num_pages is deprecated and will be removed from next major or minor release')
subscriber = ActionView::LogSubscriber.log_subscribers.detect {|ls| ls.is_a? ActionView::LogSubscriber}
return super @window_options.merge(@options).merge :paginator => self unless subscriber
View
18 spec/helpers/helpers_spec.rb
@@ -28,6 +28,24 @@
it { should == :pagina }
end
+ describe '#to_s' do
+ before do
+ ActiveSupport::Deprecation.behavior = :stderr
+ @original_stderr, $stderr = $stderr, StringIO.new
+ end
+
+ after { $stderr = @original_stderr }
+
+ it 'should expose num_pages as local and warn for deprecation' do
+ mock(template = Object.new).render.with_any_args do |args|
+ args[:locals][:num_pages].should == 1
+ end
+ Paginator.new(template, :total_pages => 1).to_s
+
+ $stderr.string.should match(/^DEPRECATION WARNING: num_pages/)
+ end
+ end
+
#TODO test somehow...
# describe '#tagify_links' do
# def tags_with(options)
Something went wrong with that request. Please try again.