Permalink
Browse files

Merge pull request #5613 from carlosantoniodasilva/fix-build-3-0-193

Fix build for branch 3-0-stable - Ruby 1.9.3
  • Loading branch information...
2 parents e0362f7 + 4c9dec4 commit 29320dc27c14f9de74eb211b13f65df220f30eac @tenderlove tenderlove committed Mar 27, 2012
@@ -3,33 +3,6 @@
require 'active_support/core_ext/object/try'
require 'active_support/core_ext/kernel/singleton_class'
-if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ruby' && RUBY_VERSION == '1.9.3' && RUBY_PATCHLEVEL == 0
- # This is a hack to work around a bug in Ruby 1.9.3p0:
- # http://redmine.ruby-lang.org/issues/5564
- #
- # Basically, at runtime we may need to perform some encoding conversions on the templates,
- # but if the converter hasn't been loaded by Ruby beforehand (i.e. now), then it won't be
- # able to find it (due to a bug).
- #
- # However, we don't know what conversions we may need to do a runtime. So we load up a
- # text file which contains a pre-generated list of all the possible conversions,
- # and we load all of them.
- #
- # In my testing this increased the process size by about 3.9 MB (after the conversions array
- # is GC'd) and took around 170ms to run, which seems acceptable for a workaround.
- #
- # The script to dump the conversions is: https://gist.github.com/1371499
-
- filename = File.join(File.dirname(__FILE__), 'data', 'encoding_conversions.txt')
- conversions = File.read(filename)
- conversions.split("\n").map do |line|
- from, to_array = line.split(':')
- to_array.split(',').each do |to|
- Encoding::Converter.new(from, to)
- end
- end
-end
-
module ActionView
# = Action View Template
class Template
@@ -82,12 +82,11 @@ def test_no_magic_comment_word_with_utf_8
# is set to something other than UTF-8, we don't
# get any errors and get back a UTF-8 String.
def test_default_external_works
- Encoding.default_external = "ISO-8859-1"
- @template = new_template("hello \xFCmlat")
- assert_equal Encoding::UTF_8, render.encoding
- assert_equal "hello \u{fc}mlat", render
- ensure
- Encoding.default_external = "UTF-8"
+ with_external_encoding "ISO-8859-1" do
+ @template = new_template("hello \xFCmlat")
+ assert_equal Encoding::UTF_8, render.encoding
+ assert_equal "hello \u{fc}mlat", render
+ end
end
def test_encoding_can_be_specified_with_magic_comment
@@ -123,10 +122,12 @@ def test_error_when_template_isnt_valid_utf8
end
def with_external_encoding(encoding)
- old, Encoding.default_external = Encoding.default_external, encoding
+ old = Encoding.default_external
+ Encoding::Converter.new old, encoding if old != encoding
+ silence_warnings { Encoding.default_external = encoding }
yield
ensure
- Encoding.default_external = old
+ silence_warnings { Encoding.default_external = old }
end
def test_render_inline_safebuffer_should_not_raise_error

0 comments on commit 29320dc

Please sign in to comment.