aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2017-06-24 14:41:10 +0200
committerGitHub <noreply@github.com>2017-06-24 14:41:10 +0200
commit8cad811b0559661df3c58528ac1e8d5a2e601d4d (patch)
tree3ba3af3eee68b7b6e3fec083005be9092caf38b3
parentcb651b3b89de849550c1f4ff412c262a51e29b9e (diff)
parentb3966080cc825755ea665693b9529c8ef898c6cb (diff)
downloadrails-8cad811b0559661df3c58528ac1e8d5a2e601d4d.tar.gz
rails-8cad811b0559661df3c58528ac1e8d5a2e601d4d.tar.bz2
rails-8cad811b0559661df3c58528ac1e8d5a2e601d4d.zip
Merge pull request #29553 from eugeneius/wrap_parameters_nil
Don't wrap parameters if key already exists
-rw-r--r--actionpack/lib/action_controller/metal/params_wrapper.rb2
-rw-r--r--actionpack/test/controller/params_wrapper_test.rb8
2 files changed, 9 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/metal/params_wrapper.rb b/actionpack/lib/action_controller/metal/params_wrapper.rb
index 68881b8402..44151c9f71 100644
--- a/actionpack/lib/action_controller/metal/params_wrapper.rb
+++ b/actionpack/lib/action_controller/metal/params_wrapper.rb
@@ -282,7 +282,7 @@ module ActionController
return false unless request.has_content_type?
ref = request.content_mime_type.ref
- _wrapper_formats.include?(ref) && _wrapper_key && !request.request_parameters[_wrapper_key]
+ _wrapper_formats.include?(ref) && _wrapper_key && !request.request_parameters.key?(_wrapper_key)
end
end
end
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"