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.
This commit is contained in:
Vitalii Khustochka 2020-06-27 16:45:41 -05:00
parent a9336a67b0
commit 5b6aa8c20a
2 changed files with 7 additions and 1 deletions

View File

@ -91,7 +91,7 @@ module ActionController
end
end
path_parameters[key] = value
path_parameters[key.to_sym] = value
end
end

View File

@ -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" }