From 5b6aa8c20a3abfd6274c83f196abf73cacb3400b Mon Sep 17 00:00:00 2001 From: Vitalii Khustochka Date: Sat, 27 Jun 2020 16:45:41 -0500 Subject: [PATCH] Path parameter keys should always be symbols. If request format is JSON, keys are converted to Strings, so we have to convert them to Symbols. --- actionpack/lib/action_controller/test_case.rb | 2 +- actionpack/test/controller/test_case_test.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index 154e3d0a13..bc7ba87cb1 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -91,7 +91,7 @@ module ActionController end end - path_parameters[key] = value + path_parameters[key.to_sym] = value end end diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb index 0cfe58972f..2a3afbf449 100644 --- a/actionpack/test/controller/test_case_test.rb +++ b/actionpack/test/controller/test_case_test.rb @@ -613,6 +613,12 @@ XML assert_equal({ "bar" => [] }, JSON.load(response.body)["foo"]) end + def test_using_as_json_with_path_parameters + post :test_params, params: { id: "12345" }, as: :json + + assert_equal("12345", @request.path_parameters[:id]) + end + def test_mutating_content_type_headers_for_plain_text_files_sets_the_header @request.headers["Content-Type"] = "text/plain" post :render_body, params: { name: "foo.txt" }