Permalink
Browse files

stop supporting WillPaginate::Collection#page_count legacy method

  • Loading branch information...
1 parent eacd19a commit 1c625fc10d9e25441cf35f7abd570087a4c59edf @mislav mislav committed Oct 12, 2008
@@ -35,20 +35,5 @@ def self.pagination_options=(value) @pagination_options = value; end
:page_links => true,
:container => true
}
-
- def self.total_pages_for_collection(collection) #:nodoc:
- if collection.respond_to?('page_count') and !collection.respond_to?('total_pages')
- WillPaginate::Deprecation.warn <<-MSG
- You are using a paginated collection of class #{collection.class.name}
- which conforms to the old API of WillPaginate::Collection by using
- `page_count`, while the current method name is `total_pages`. Please
- upgrade yours or 3rd-party code that provides the paginated collection.
- MSG
- class << collection
- def total_pages; page_count; end
- end
- end
- collection.total_pages
- end
end
end
@@ -50,7 +50,7 @@ module Base
#
def will_paginate(collection, options = {})
# early exit if there is nothing to render
- return nil unless WillPaginate::ViewHelpers.total_pages_for_collection(collection) > 1
+ return nil unless collection.total_pages > 1
options = WillPaginate::ViewHelpers.pagination_options.merge(options)
@@ -65,7 +65,7 @@ def current_page
end
def total_pages
- @total_pages ||= WillPaginate::ViewHelpers.total_pages_for_collection(@collection)
+ @collection.total_pages
end
def param_name
@@ -2,11 +2,6 @@
require 'will_paginate/view_helpers/link_renderer_base'
require 'will_paginate/collection'
-class LegacyCollection < WillPaginate::Collection
- alias :page_count :total_pages
- undef :total_pages
-end
-
describe WillPaginate::ViewHelpers::LinkRendererBase do
before do
@@ -32,13 +27,6 @@ class LegacyCollection < WillPaginate::Collection
}.should_not have_deprecation
end
- it "should log deprecation warnings for legacy collections" do
- @renderer.prepare(LegacyCollection.new(1, 1, 2), {})
- lambda {
- @renderer.send(:total_pages).should == 2
- }.should have_deprecation
- end
-
it "should clear old cached values when prepared" do
prepare({ :total_pages => 1 }, :param_name => 'foo')
@renderer.send(:total_pages).should == 1

0 comments on commit 1c625fc

Please sign in to comment.