1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

make actionview templates marshalable so that they can be serialized during the parallel tests (#34030)

This commit is contained in:
lsylvester 2018-10-01 09:50:57 +10:00 committed by David Heinemeier Hansson
parent 09f92a1b98
commit 9d7d6336d7
2 changed files with 16 additions and 0 deletions

View file

@ -235,6 +235,15 @@ module ActionView
end
end
def marshal_dump
[ @source, @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @formats, @variants ]
end
def marshal_load(array)
@source, @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @formats, @variants = *array
@compile_mutex = Mutex.new
end
private
# Compile a template. This method ensures a template is compiled

View file

@ -196,6 +196,13 @@ class TestERBTemplate < ActiveSupport::TestCase
assert_match(Regexp.new("\xFC"), e.message)
end
def test_template_is_marshalable
template = new_template
serialized = Marshal.load(Marshal.dump(template))
assert_equal template.identifier, serialized.identifier
assert_equal template.source, serialized.source
end
def with_external_encoding(encoding)
old = Encoding.default_external
Encoding::Converter.new old, encoding if old != encoding