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:
parent
09f92a1b98
commit
9d7d6336d7
2 changed files with 16 additions and 0 deletions
|
@ -235,6 +235,15 @@ module ActionView
|
||||||
end
|
end
|
||||||
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
|
private
|
||||||
|
|
||||||
# Compile a template. This method ensures a template is compiled
|
# Compile a template. This method ensures a template is compiled
|
||||||
|
|
|
@ -196,6 +196,13 @@ class TestERBTemplate < ActiveSupport::TestCase
|
||||||
assert_match(Regexp.new("\xFC"), e.message)
|
assert_match(Regexp.new("\xFC"), e.message)
|
||||||
end
|
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)
|
def with_external_encoding(encoding)
|
||||||
old = Encoding.default_external
|
old = Encoding.default_external
|
||||||
Encoding::Converter.new old, encoding if old != encoding
|
Encoding::Converter.new old, encoding if old != encoding
|
||||||
|
|
Loading…
Reference in a new issue