Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

update the PageNumber class to raise no ArgumentError #275

Closed
wants to merge 1 commit into from

1 participant

@rocknruby

my commit changed the page_number.rb and the AR Test and fixed the issue #271

I guess it would be better to check this by the application itself but maybe it´s helpful.

@rocknruby rocknruby closed this
@rocknruby rocknruby reopened this
@rocknruby rocknruby closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 5, 2012
  1. get page number one for invalid page_numbers

    Hannes Maack authored
This page is out of date. Refresh to see the latest.
View
1  lib/will_paginate/page_number.rb
@@ -13,6 +13,7 @@ class PageNumber < DelegateClass(Integer)
extend Forwardable
def initialize(value, name)
+ value = 1 if value.is_a?(String) and value.to_i == 0
value = Integer(value)
if 'offset' == name ? (value < 0 or value > BIGINT) : value < 1
raise RangeError, "invalid #{name}: #{value.inspect}"
View
9 spec/finders/active_record_spec.rb
@@ -76,10 +76,11 @@
rel.offset.should == 5
end
- it "raises on invalid page number" do
- lambda {
- Developer.page('foo')
- }.should raise_error(ArgumentError)
+ it "get page one for invalid strings" do
+ rel = Developer.page('foo')
+ rel.current_page.should == 1
+ rel.per_page.should == 10
+ rel.offset.should == 0
end
it "supports first limit() then page()" do
Something went wrong with that request. Please try again.