Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit db2769ef48b2b498e2aeb5003cfeeb2cda473652 1 parent 87f0848
@tricknotes tricknotes authored
View
2  lib/routing_filter/filters/pagination.rb
@@ -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
View
26 test/filters/all_filters/recognition.rb
@@ -12,7 +12,7 @@ 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
@@ -20,7 +20,7 @@ module Recognition
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,14 +53,14 @@ 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
@@ -68,25 +68,25 @@ module Recognition
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
View
4 test/filters/pagination_test.rb
@@ -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
4 test/rails_test.rb
@@ -45,7 +45,7 @@ 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
@@ -53,7 +53,7 @@ def params
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
Please sign in to comment.
Something went wrong with that request. Please try again.