aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2016-08-19 01:42:21 -0300
committerGitHub <noreply@github.com>2016-08-19 01:42:21 -0300
commit03b9a11f93e235f803a7029e9a31dd11127f8f3e (patch)
tree06b413129a9a80ac9008e8f03cd9b8396a58d270 /actionpack/test
parente87158f16b2a85beed690620a5f5e6d57ee505e3 (diff)
parent3db57bde1ef435a38337f6db298b851c8a4ad10c (diff)
downloadrails-03b9a11f93e235f803a7029e9a31dd11127f8f3e.tar.gz
rails-03b9a11f93e235f803a7029e9a31dd11127f8f3e.tar.bz2
rails-03b9a11f93e235f803a7029e9a31dd11127f8f3e.zip
Merge pull request #26212 from evmunro/as-json-sets-request-to-json-for-controller-test
Allow setting of request CONTENT-TYPE with as: in controller tests
Diffstat (limited to 'actionpack/test')
-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" }