Permalink
Browse files

Make sure apps upgrading from 2.3 get defaulted to UTF-8 (ht: parndt)

  • Loading branch information...
1 parent a1fdf40 commit aaec0072922166442457ded88c39cb5372ea5e67 @wycats wycats committed Aug 15, 2010
Showing with 16 additions and 6 deletions.
  1. +1 −1 railties/lib/rails/application/configuration.rb
  2. +15 −5 railties/test/application/configuration_test.rb
@@ -16,9 +16,9 @@ class Configuration < ::Rails::Engine::Configuration
def initialize(*)
super
+ self.encoding = "utf-8"
@allow_concurrency = false
@consider_all_requests_local = false
- @encoding = "utf-8"
@filter_parameters = []
@dependency_loading = true
@serve_static_assets = true
@@ -172,17 +172,27 @@ def teardown
assert $prepared
end
+ def assert_utf8
+ if RUBY_VERSION < '1.9'
+ assert_equal "UTF8", $KCODE
+ else
+ assert_equal Encoding::UTF_8, Encoding.default_external
+ assert_equal Encoding::UTF_8, Encoding.default_internal
+ end
+ end
+
+ test "skipping config.encoding still results in 'utf-8' as the default" do
+ require "#{app_path}/config/application"
+ assert_utf8
+ end
+
test "config.encoding sets the default encoding" do
add_to_config <<-RUBY
config.encoding = "utf-8"
RUBY
require "#{app_path}/config/application"
-
- unless RUBY_VERSION < '1.9'
- assert_equal Encoding::UTF_8, Encoding.default_external
- assert_equal Encoding::UTF_8, Encoding.default_internal
- end
+ assert_utf8
end
test "config.paths.public sets Rails.public_path" do

0 comments on commit aaec007

Please sign in to comment.