From d87427c6c75c4d8573ea77a7447c6ab1a3dcde9d Mon Sep 17 00:00:00 2001 From: Gaurav Sharma Date: Fri, 2 Oct 2015 01:27:23 +0530 Subject: adding test for content type with default charset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * first test is for `default_charset` i.e `ActionDispatch::Response.default_charset = “utf-8”` * In below test we are passing `ActionDispatch::Response.default_charset = 'utf-16’` so name of the test is irrelevant — “read content type without charset” --- actionpack/test/dispatch/response_test.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'actionpack/test') diff --git a/actionpack/test/dispatch/response_test.rb b/actionpack/test/dispatch/response_test.rb index 85cdcda655..fa29f3a6c4 100644 --- a/actionpack/test/dispatch/response_test.rb +++ b/actionpack/test/dispatch/response_test.rb @@ -196,7 +196,17 @@ class ResponseTest < ActiveSupport::TestCase assert_equal('application/xml; charset=utf-16', resp.headers['Content-Type']) end - test "read content type without charset" do + test "read content type with default charset utf-8" do + original = ActionDispatch::Response.default_charset + begin + resp = ActionDispatch::Response.new(200, { "Content-Type" => "text/xml" }) + assert_equal('utf-8', resp.charset) + ensure + ActionDispatch::Response.default_charset = original + end + end + + test "read content type with charset utf-16" do jruby_skip "https://github.com/jruby/jruby/issues/3138" original = ActionDispatch::Response.default_charset -- cgit v1.2.3