diff --git a/actionpack/lib/action_controller/metal/compatibility.rb b/actionpack/lib/action_controller/metal/compatibility.rb index 813b6501d17d6..0f43bc8cce108 100644 --- a/actionpack/lib/action_controller/metal/compatibility.rb +++ b/actionpack/lib/action_controller/metal/compatibility.rb @@ -4,10 +4,6 @@ module Compatibility # Temporary hax included do - class << self - delegate :default_charset=, :to => "ActionDispatch::Response" - end - self.protected_instance_variables = [ :@_status, :@_headers, :@_params, :@_env, :@_response, :@_request, :@_view_runtime, :@_stream, :@_url_options, :@_action_has_layout diff --git a/actionpack/lib/action_dispatch/railtie.rb b/actionpack/lib/action_dispatch/railtie.rb index 46c06386d83dc..35f901c5751a1 100644 --- a/actionpack/lib/action_dispatch/railtie.rb +++ b/actionpack/lib/action_dispatch/railtie.rb @@ -11,6 +11,7 @@ class Railtie < Rails::Railtie config.action_dispatch.ignore_accept_header = false config.action_dispatch.rescue_templates = { } config.action_dispatch.rescue_responses = { } + config.action_dispatch.default_charset = nil config.action_dispatch.rack_cache = { :metastore => "rails:/", @@ -21,7 +22,7 @@ class Railtie < Rails::Railtie initializer "action_dispatch.configure" do |app| ActionDispatch::Http::URL.tld_length = app.config.action_dispatch.tld_length ActionDispatch::Request.ignore_accept_header = app.config.action_dispatch.ignore_accept_header - ActionDispatch::Response.default_charset = app.config.encoding + ActionDispatch::Response.default_charset = app.config.action_dispatch.default_charset || app.config.encoding ActionDispatch::ExceptionWrapper.rescue_responses.merge!(config.action_dispatch.rescue_responses) ActionDispatch::ExceptionWrapper.rescue_templates.merge!(config.action_dispatch.rescue_templates) diff --git a/actionpack/test/controller/content_type_test.rb b/actionpack/test/controller/content_type_test.rb index b57f3f1bb5a8e..03d5d27cf47e2 100644 --- a/actionpack/test/controller/content_type_test.rb +++ b/actionpack/test/controller/content_type_test.rb @@ -68,12 +68,12 @@ def test_render_defaults end def test_render_changed_charset_default - OldContentTypeController.default_charset = "utf-16" + ActionDispatch::Response.default_charset = "utf-16" get :render_defaults assert_equal "utf-16", @response.charset assert_equal Mime::HTML, @response.content_type ensure - OldContentTypeController.default_charset = "utf-8" + ActionDispatch::Response.default_charset = "utf-8" end # :ported: @@ -105,12 +105,12 @@ def test_nil_charset_from_body end def test_nil_default_for_erb - OldContentTypeController.default_charset = nil + ActionDispatch::Response.default_charset = nil get :render_default_for_erb assert_equal Mime::HTML, @response.content_type assert_nil @response.charset, @response.headers.inspect ensure - OldContentTypeController.default_charset = "utf-8" + ActionDispatch::Response.default_charset = "utf-8" end def test_default_for_erb diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 397f4da8fc725..cadf60d46f364 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -287,6 +287,14 @@ def index assert_equal Rails.application, ActionDispatch.test_app end + test "sets ActionDispatch::Response.default_charset" do + make_basic_app do |app| + app.config.action_dispatch.default_charset = "utf-16" + end + + assert_equal "utf-16", ActionDispatch::Response.default_charset + end + test "sets all Active Record models to whitelist all attributes by default" do add_to_config <<-RUBY config.active_record.whitelist_attributes = true