diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-01-17 08:56:50 -0200 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-01-17 10:04:39 -0200 |
commit | cb650a50bfc561dc00dfc844dac01beeab05bd00 (patch) | |
tree | 8be9c376e2d580202b0db8da544c6e10a6f3ff5a | |
parent | 67c96ab024f008ad1aee8345c1ae0fd7aa9bf072 (diff) | |
download | rails-cb650a50bfc561dc00dfc844dac01beeab05bd00.tar.gz rails-cb650a50bfc561dc00dfc844dac01beeab05bd00.tar.bz2 rails-cb650a50bfc561dc00dfc844dac01beeab05bd00.zip |
Remove deprecated default_charset= from AC::Base
This should be set globally as a configuration, using
`config.action_dispatch.default_charset` instead
4 files changed, 14 insertions, 9 deletions
diff --git a/actionpack/lib/action_controller/metal/compatibility.rb b/actionpack/lib/action_controller/metal/compatibility.rb index 813b6501d1..0f43bc8cce 100644 --- a/actionpack/lib/action_controller/metal/compatibility.rb +++ b/actionpack/lib/action_controller/metal/compatibility.rb @@ -4,10 +4,6 @@ module ActionController # 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 46c06386d8..35f901c575 100644 --- a/actionpack/lib/action_dispatch/railtie.rb +++ b/actionpack/lib/action_dispatch/railtie.rb @@ -11,6 +11,7 @@ module ActionDispatch 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 @@ module ActionDispatch 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 b57f3f1bb5..03d5d27cf4 100644 --- a/actionpack/test/controller/content_type_test.rb +++ b/actionpack/test/controller/content_type_test.rb @@ -68,12 +68,12 @@ class ContentTypeTest < ActionController::TestCase 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 @@ class ContentTypeTest < ActionController::TestCase 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 397f4da8fc..cadf60d46f 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -287,6 +287,14 @@ module ApplicationTests 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 |