Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

update the PageNumber class to raise no ArgumentError #275

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+6 −4
Split
@@ -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}"
@@ -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