Permalink
Browse files

Deprecate default_charset= at controller level

  • Loading branch information...
1 parent 20baeec commit 57be2cfa1eb5cf04c86f4ab5461f6903df099b98 @carlosantoniodasilva carlosantoniodasilva committed Jan 17, 2012
@@ -16,8 +16,10 @@ class ::ActionController::ActionControllerError < StandardError #:nodoc:
# should be able to handle SCRIPT_NAME
self.config.relative_url_root = ENV['RAILS_RELATIVE_URL_ROOT']
- class << self
- delegate :default_charset=, :to => "ActionDispatch::Response"
+ def self.default_charset=(new_charset)
+ ActiveSupport::Deprecation.warn "Setting default charset at controller level" \
+ " is deprecated, please use `config.action_dispatch.default_charset` instead", caller
+ ActionDispatch::Response.default_charset = new_charset
end
self.protected_instance_variables = %w(
@@ -70,12 +70,16 @@ def test_render_defaults
end
def test_render_changed_charset_default
- OldContentTypeController.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"
+ assert_deprecated /Setting default charset at controller.*config\.action_dispatch\.default_charset/ do
+ begin
+ OldContentTypeController.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"
+ end
+ end
end
# :ported:
@@ -107,12 +111,16 @@ def test_nil_charset_from_body
end
def test_nil_default_for_erb
- OldContentTypeController.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"
+ assert_deprecated /Setting default charset at controller.*config\.action_dispatch\.default_charset/ do
+ begin
+ OldContentTypeController.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"
+ end
+ end
end
def test_default_for_erb

0 comments on commit 57be2cf

Please sign in to comment.