aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/test_case_test.rb
diff options
context:
space:
mode:
authorEverest Munro-Zeisberger <everest.munrozeisberger@shopify.com>2016-08-18 14:00:38 -0400
committerEverest Munro-Zeisberger <everest.munrozeisberger@shopify.com>2016-08-18 18:09:23 -0400
commit3db57bde1ef435a38337f6db298b851c8a4ad10c (patch)
treebd93a6050848ff1b6fdcd79fae540befe7c25a62 /actionpack/test/controller/test_case_test.rb
parentfd0c33d7cc8dd06083f543cf531ab1f4c52c6a6e (diff)
downloadrails-3db57bde1ef435a38337f6db298b851c8a4ad10c.tar.gz
rails-3db57bde1ef435a38337f6db298b851c8a4ad10c.tar.bz2
rails-3db57bde1ef435a38337f6db298b851c8a4ad10c.zip
Set the request type if as: is specified
Documentation & testing
Diffstat (limited to 'actionpack/test/controller/test_case_test.rb')
-rw-r--r--actionpack/test/controller/test_case_test.rb9
1 files changed, 9 insertions, 0 deletions
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" }