Skip to content
This repository
Browse code

Add default charset config to ActionDispatch

  • Loading branch information...
commit 9d4fd613a69378b38b061580e6b979e61fe9a823 1 parent 57be2cf
Carlos Antonio da Silva authored January 17, 2012
3  actionpack/lib/action_dispatch/railtie.rb
@@ -11,6 +11,7 @@ class Railtie < Rails::Railtie
11 11
     config.action_dispatch.ignore_accept_header = false
12 12
     config.action_dispatch.rescue_templates = { }
13 13
     config.action_dispatch.rescue_responses = { }
  14
+    config.action_dispatch.default_charset = nil
14 15
 
15 16
     config.action_dispatch.rack_cache = {
16 17
       :metastore => "rails:/",
@@ -21,7 +22,7 @@ class Railtie < Rails::Railtie
21 22
     initializer "action_dispatch.configure" do |app|
22 23
       ActionDispatch::Http::URL.tld_length = app.config.action_dispatch.tld_length
23 24
       ActionDispatch::Request.ignore_accept_header = app.config.action_dispatch.ignore_accept_header
24  
-      ActionDispatch::Response.default_charset = app.config.encoding
  25
+      ActionDispatch::Response.default_charset = app.config.action_dispatch.default_charset || app.config.encoding
25 26
 
26 27
       ActionDispatch::ExceptionWrapper.rescue_responses.merge!(config.action_dispatch.rescue_responses)
27 28
       ActionDispatch::ExceptionWrapper.rescue_templates.merge!(config.action_dispatch.rescue_templates)
8  railties/test/application/configuration_test.rb
@@ -286,6 +286,14 @@ def index
286 286
       assert_equal res, last_response.body # value should be unchanged
287 287
     end
288 288
 
  289
+    test "sets ActionDispatch::Response.default_charset" do
  290
+      make_basic_app do |app|
  291
+        app.config.action_dispatch.default_charset = "utf-16"
  292
+      end
  293
+
  294
+      assert_equal "utf-16", ActionDispatch::Response.default_charset
  295
+    end
  296
+
289 297
     test "sets all Active Record models to whitelist all attributes by default" do
290 298
       add_to_config <<-RUBY
291 299
         config.active_record.whitelist_attributes = true

0 notes on commit 9d4fd61

Please sign in to comment.
Something went wrong with that request. Please try again.