Skip to content

Commit

Permalink
Add default charset config to ActionDispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosantoniodasilva committed Jan 17, 2012
1 parent 57be2cf commit 9d4fd61
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion actionpack/lib/action_dispatch/railtie.rb
Expand Up @@ -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:/",
Expand All @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions railties/test/application/configuration_test.rb
Expand Up @@ -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
Expand Down

0 comments on commit 9d4fd61

Please sign in to comment.