diff options
author | Yuji Yaginuma <yuuji.yaginuma@gmail.com> | 2019-06-21 09:04:30 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-21 09:04:30 +0900 |
commit | c631e8d011a7cf3e7ade4e9e8db56d2b89bd530c (patch) | |
tree | ce404d935851ec89e426e7538067276cc5a7e885 /actionpack/test | |
parent | 3218459c28737071fe4424cd375c1b06a5c317df (diff) | |
parent | ddb6d788d6a611fd1ba6cf92ad6d1342079517a8 (diff) | |
download | rails-c631e8d011a7cf3e7ade4e9e8db56d2b89bd530c.tar.gz rails-c631e8d011a7cf3e7ade4e9e8db56d2b89bd530c.tar.bz2 rails-c631e8d011a7cf3e7ade4e9e8db56d2b89bd530c.zip |
Merge pull request #36490 from y-yagi/revise_36034
Make `ActionDispatch::Response#content_type` behavior configurable
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/dispatch/response_test.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/response_test.rb b/actionpack/test/dispatch/response_test.rb index 33cf86a081..ed64d89902 100644 --- a/actionpack/test/dispatch/response_test.rb +++ b/actionpack/test/dispatch/response_test.rb @@ -593,4 +593,33 @@ class ResponseIntegrationTest < ActionDispatch::IntegrationTest assert_equal("text/csv", @response.media_type) assert_equal("utf-16", @response.charset) end + + test "`content type` returns header that excludes `charset` when specified `return_only_media_type_on_content_type`" do + original = ActionDispatch::Response.return_only_media_type_on_content_type + ActionDispatch::Response.return_only_media_type_on_content_type = true + + @app = lambda { |env| + if env["PATH_INFO"] == "/with_parameters" + [200, { "Content-Type" => "text/csv; header=present; charset=utf-16" }, [""]] + else + [200, { "Content-Type" => "text/csv; charset=utf-16" }, [""]] + end + } + + get "/" + assert_response :success + + assert_deprecated do + assert_equal("text/csv", @response.content_type) + end + + get "/with_parameters" + assert_response :success + + assert_deprecated do + assert_equal("text/csv; header=present", @response.content_type) + end + ensure + ActionDispatch::Response.return_only_media_type_on_content_type = original + end end |