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

This commit is contained in:
wycats 2010-08-15 16:29:27 -07:00
parent a1fdf402c0
commit aaec007292
2 changed files with 16 additions and 6 deletions

@ -16,9 +16,9 @@ class Configuration < ::Rails::Engine::Configuration
def initialize(*) def initialize(*)
super super
self.encoding = "utf-8"
@allow_concurrency = false @allow_concurrency = false
@consider_all_requests_local = false @consider_all_requests_local = false
@encoding = "utf-8"
@filter_parameters = [] @filter_parameters = []
@dependency_loading = true @dependency_loading = true
@serve_static_assets = true @serve_static_assets = true

@ -172,17 +172,27 @@ def teardown
assert $prepared assert $prepared
end 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 test "config.encoding sets the default encoding" do
add_to_config <<-RUBY add_to_config <<-RUBY
config.encoding = "utf-8" config.encoding = "utf-8"
RUBY RUBY
require "#{app_path}/config/application" require "#{app_path}/config/application"
assert_utf8
unless RUBY_VERSION < '1.9'
assert_equal Encoding::UTF_8, Encoding.default_external
assert_equal Encoding::UTF_8, Encoding.default_internal
end
end end
test "config.paths.public sets Rails.public_path" do test "config.paths.public sets Rails.public_path" do