aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/routing_test.rb
diff options
context:
space:
mode:
authorPrathamesh Sonpatki <csonpatki@gmail.com>2016-01-03 17:20:24 +0530
committerPrathamesh Sonpatki <csonpatki@gmail.com>2016-01-07 12:12:34 +0530
commita31078556a82ded9cb13c71727e146bb716a17ec (patch)
tree7a609e2e139c92d839ecc7249263f4201acc0ee4 /actionpack/test/dispatch/routing_test.rb
parent3cae35bd6c46c7fb4b2daf09d1a8713feb74a0e3 (diff)
downloadrails-a31078556a82ded9cb13c71727e146bb716a17ec.tar.gz
rails-a31078556a82ded9cb13c71727e146bb716a17ec.tar.bz2
rails-a31078556a82ded9cb13c71727e146bb716a17ec.zip
Allow AC::Parameters as an argument to url_helpers
- Earlier only Hash was allowed as params argument to url_helpers. - Now ActionController::Parameters instances will also be allowed. - If the params are not secured then it will raise an ArgumentError to indicate that constructing URLs with non-secure params is not recommended. - Fixes #22832.
Diffstat (limited to 'actionpack/test/dispatch/routing_test.rb')
-rw-r--r--actionpack/test/dispatch/routing_test.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 82222a141c..62d65ec5c0 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -3578,6 +3578,27 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
assert_equal 'HEAD', @response.body
end
+ def test_passing_action_parameters_to_url_helpers_raises_error_if_parameters_are_not_permitted
+ draw do
+ root :to => 'projects#index'
+ end
+ params = ActionController::Parameters.new(id: '1')
+
+ assert_raises ArgumentError do
+ root_path(params)
+ end
+ end
+
+ def test_passing_action_parameters_to_url_helpers_is_allowed_if_parameters_are_permitted
+ draw do
+ root :to => 'projects#index'
+ end
+ params = ActionController::Parameters.new(id: '1')
+ params.permit!
+
+ assert_equal '/?id=1', root_path(params)
+ end
+
private
def draw(&block)