From 3db57bde1ef435a38337f6db298b851c8a4ad10c Mon Sep 17 00:00:00 2001 From: Everest Munro-Zeisberger Date: Thu, 18 Aug 2016 14:00:38 -0400 Subject: Set the request type if as: is specified Documentation & testing --- actionpack/test/controller/test_case_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb index 2d78fc71a9..696794a3eb 100644 --- a/actionpack/test/controller/test_case_test.rb +++ b/actionpack/test/controller/test_case_test.rb @@ -637,6 +637,15 @@ XML assert_equal "application/json", parsed_env["CONTENT_TYPE"] end + def test_using_as_json_sets_request_content_type_to_json + post :render_body, params: { bool_value: true, str_value: "string", num_value: 2 }, as: :json + + assert_equal "application/json", @request.headers["CONTENT_TYPE"] + assert_equal true, @request.request_parameters[:bool_value] + assert_equal "string", @request.request_parameters[:str_value] + assert_equal 2, @request.request_parameters[:num_value] + 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" } -- cgit v1.2.3