Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add default charset config to ActionDispatch

  • Loading branch information...
commit 9d4fd613a69378b38b061580e6b979e61fe9a823 1 parent 57be2cf
@carlosantoniodasilva carlosantoniodasilva authored
View
3  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)
View
8 railties/test/application/configuration_test.rb
@@ -286,6 +286,14 @@ def index
assert_equal res, last_response.body # value should be unchanged
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
Please sign in to comment.
Something went wrong with that request. Please try again.