Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix issue #284 #288

Closed
wants to merge 1 commit into from

3 participants

@eitoball

This pull request should fix issue #284.

@hsbt
Collaborator

@amatsuda I should applying this pull request. What do you think about it?

@yuki24
Collaborator

@hsbt san, What about defining #num_pages like this?

def num_pages
  ActiveSupport::Deprecation.warn "#num_pages is deprecated and ..."
  params[:total_pages]
end

I don't like seeing the warning message every time I call Paginator#to_s.

@yuki24
Collaborator

I'll close this issue and keep #287 open since these are similar to each other. Please be patient for the fix.

@yuki24 yuki24 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 15, 2012
  1. @eitoball

    fix issue#284

    eitoball authored
This page is out of date. Refresh to see the latest.
Showing with 20 additions and 1 deletion.
  1. +2 −1  lib/kaminari/helpers/paginator.rb
  2. +18 −0 spec/helpers/helpers_spec.rb
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.