aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
authorEugene Kenny <elkenny@gmail.com>2017-06-24 00:48:34 +0100
committerEugene Kenny <elkenny@gmail.com>2017-06-24 00:48:34 +0100
commitb3966080cc825755ea665693b9529c8ef898c6cb (patch)
treeeb18b0f6806fce033918e21144ec6bb7251fb83c /actionpack/test/controller
parent2477e1b5aa66e8308244af17abf56474d4266536 (diff)
downloadrails-b3966080cc825755ea665693b9529c8ef898c6cb.tar.gz
rails-b3966080cc825755ea665693b9529c8ef898c6cb.tar.bz2
rails-b3966080cc825755ea665693b9529c8ef898c6cb.zip
Don't wrap parameters if key already exists
We shouldn't perform parameter wrapping if it would overwrite one of the parameters sent with the request, as that would interfere with reading the parameter directly from the top level `params` hash. The current implementation has logic for this case, but it doesn't handle `nil`/`false` values, which means these parameters: { "user" => nil } are transformed into this `params` hash: { "user" => { "user" => nil } } and `params["user"]` no longer returns the original parameter value.
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/params_wrapper_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/actionpack/test/controller/params_wrapper_test.rb b/actionpack/test/controller/params_wrapper_test.rb
index 2a41d57b26..4cbb28ef60 100644
--- a/actionpack/test/controller/params_wrapper_test.rb
+++ b/actionpack/test/controller/params_wrapper_test.rb
@@ -170,6 +170,14 @@ class ParamsWrapperTest < ActionController::TestCase
end
end
+ def test_no_double_wrap_if_key_exists_and_value_is_nil
+ with_default_wrapper_options do
+ @request.env["CONTENT_TYPE"] = "application/json"
+ post :parse, params: { "user" => nil }
+ assert_parameters("user" => nil)
+ end
+ end
+
def test_nested_params
with_default_wrapper_options do
@request.env["CONTENT_TYPE"] = "application/json"