Permalink
Browse files

Parameter shouldn't be convert to numeric

THIS IS A BREAKING CHANGE.

The values of `params` should be given as a `String`.
And Action Pack 4 expects these to be instance of `String`.
  • Loading branch information...
1 parent 87f0848 commit db2769ef48b2b498e2aeb5003cfeeb2cda473652 @tricknotes tricknotes committed Mar 1, 2013
@@ -27,7 +27,7 @@ class Pagination < Filter
def around_recognize(path, env, &block)
page = extract_segment!(PAGINATION_SEGMENT, path)
yield.tap do |params|
- params[:page] = page.to_i if page
+ params[:page] = page if page
end
end
@@ -12,15 +12,15 @@ module Recognition
end
test 'recognizes the path /some/page/2 (pagination)' do
- params = self.params.merge(:page => 2)
+ params = self.params.merge(:page => '2')
assert_equal params, routes.recognize_path('/some/page/2')
end
test 'recognizes the path /:uuid/some (uuid)' do
params = self.params.merge(:uuid => uuid)
assert_equal params, routes.recognize_path("/#{uuid}/some")
end
-
+
# extension with any
test 'recognizes the path /de/some.html (extension, locale)' do
@@ -29,7 +29,7 @@ module Recognition
end
test 'recognizes the path /some/page/2.html (extension, pagination)' do
- params = self.params.merge(:page => 2)
+ params = self.params.merge(:page => '2')
assert_equal params, routes.recognize_path('/some/page/2.html')
end
@@ -41,7 +41,7 @@ module Recognition
# locale with any
test 'recognizes the path /de/some/page/2 (locale, pagination)' do
- params = self.params.merge(:locale => 'de', :page => 2)
+ params = self.params.merge(:locale => 'de', :page => '2')
assert_equal params, routes.recognize_path('/de/some/page/2')
end
@@ -53,40 +53,40 @@ module Recognition
# pagination with any
test 'recognizes the path /:uuid/some/page/2 (pagination, uuid)' do
- params = self.params.merge(:page => 2, :uuid => uuid)
+ params = self.params.merge(:page => '2', :uuid => uuid)
assert_equal params, routes.recognize_path("/#{uuid}/some/page/2")
end
# extension, locale with any
test 'recognizes the path /de/some/page/2.html (extension, locale, pagination)' do
- params = self.params.merge(:locale => 'de', :page => 2)
+ params = self.params.merge(:locale => 'de', :page => '2')
assert_equal params, routes.recognize_path("/de/some/page/2.html")
end
test 'recognizes the path /de/:uuid/some.html (extension, locale, uuid)' do
params = self.params.merge(:locale => 'de', :uuid => uuid)
assert_equal params, routes.recognize_path("/de/#{uuid}/some.html")
end
-
+
# extension, pagination with any
test 'recognizes the path /some/page/2.html (extension, pagination, uuid)' do
- params = self.params.merge(:page => 2, :uuid => uuid)
+ params = self.params.merge(:page => '2', :uuid => uuid)
assert_equal params, routes.recognize_path("/#{uuid}/some/page/2.html")
end
-
+
# locale, pagination with any
test 'recognizes the path /de/some/page/2 (locale, pagination, uuid)' do
- params = self.params.merge(:locale => 'de', :page => 2, :uuid => uuid)
+ params = self.params.merge(:locale => 'de', :page => '2', :uuid => uuid)
assert_equal params, routes.recognize_path("/de/#{uuid}/some/page/2")
end
-
+
# all
test 'recognizes the path /de/:uuid/some/page/2.html (extension, locale, pagination, uuid)' do
- params = self.params.merge(:locale => 'de', :page => 2, :uuid => uuid)
+ params = self.params.merge(:locale => 'de', :page => '2', :uuid => uuid)
assert_equal params, routes.recognize_path("/de/#{uuid}/some/page/2.html")
end
-end
+end
@@ -8,7 +8,7 @@ def setup
filter :pagination
get 'some', :to => 'some#index'
end
- @params = { :controller => 'some', :action => 'index', :page => 2 }
+ @params = { :controller => 'some', :action => 'index', :page => '2' }
end
test 'recognizes the path some/page/2' do
@@ -20,7 +20,7 @@ def setup
end
test 'does not append anything to the generated path if the passed :page param equals 1' do
- assert_generates '/some', routes.generate(params.merge(:page => 1))
+ assert_generates '/some', routes.generate(params.merge(:page => '1'))
end
test 'appends the segments /page/:page to the generated path but respects url query params' do
View
@@ -45,15 +45,15 @@ def params
test "get to /page/2" do
get '/page/2'
assert_nil params[:locale]
- assert_equal 2, params[:page]
+ assert_equal '2', params[:page]
assert_nil params[:uuid]
assert_equal '/en/page/2.html', params[:url]
end
test "get to /foo/1/page/2" do
get '/foo/1/page/2'
assert_nil params[:locale]
- assert_equal 2, params[:page]
+ assert_equal '2', params[:page]
assert_nil params[:uuid]
assert_equal '/en/foo/1/page/2.html', params[:url]
end

0 comments on commit db2769e

Please sign in to comment.