Permalink
Browse files

Fixed param replacement boundary issue [#22]

  • Loading branch information...
1 parent b15ce2f commit 59a2c32f7dd82895e6bf3dcd670fb691cdc43ef2 @tj committed Oct 27, 2009
Showing with 12 additions and 3 deletions.
  1. +3 −3 lib/dm-pager/pager.rb
  2. +9 −0 spec/unit/pager_spec.rb
@@ -183,9 +183,9 @@ def li css_class = nil, contents = nil
def uri_for page
case @uri
- when /page=/ ; @uri.gsub /page=\d+/, "page=#{page}"
- when /\?/ ; @uri += "&page=#{page}"
- else ; @uri += "?page=#{page}"
+ when /\bpage=/ ; @uri.gsub /\bpage=\d+/, "page=#{page}"
+ when /\?/ ; @uri += "&page=#{page}"
+ else ; @uri += "?page=#{page}"
end
end
@@ -214,6 +214,15 @@
markup.should include('items?foo=bar&page=1')
end
end
+
+ describe "when containing other keys with 'page'" do
+ it "should append a pair" do
+ markup = Item.page.pager.to_html 'items?per_page=5'
+ markup.should include('items?per_page=5&page=1')
+ markup = Item.page.pager.to_html 'items?page=4&per_page=3'
+ markup.should include('items?page=1&per_page=3')
+ end
+ end
end
end

0 comments on commit 59a2c32

Please sign in to comment.