aboutsummaryrefslogtreecommitdiffstats
path: root/actionview
diff options
context:
space:
mode:
authorlsylvester <lachlan.sylvester@hypothetical.com.au>2018-10-01 09:50:57 +1000
committerDavid Heinemeier Hansson <david@loudthinking.com>2018-09-30 16:50:57 -0700
commit9d7d6336d79149c9932854517a777c3b304d7fdf (patch)
tree02400a8bfad7e3033d6badf540d631fba050183b /actionview
parent09f92a1b9883927dbeda23a0cc145a2a62a9df60 (diff)
downloadrails-9d7d6336d79149c9932854517a777c3b304d7fdf.tar.gz
rails-9d7d6336d79149c9932854517a777c3b304d7fdf.tar.bz2
rails-9d7d6336d79149c9932854517a777c3b304d7fdf.zip
make actionview templates marshalable so that they can be serialized during the parallel tests (#34030)
Diffstat (limited to 'actionview')
-rw-r--r--actionview/lib/action_view/template.rb9
-rw-r--r--actionview/test/template/template_test.rb7
2 files changed, 16 insertions, 0 deletions
diff --git a/actionview/lib/action_view/template.rb b/actionview/lib/action_view/template.rb
index 18a5dae270..2dfb14ab46 100644
--- a/actionview/lib/action_view/template.rb
+++ b/actionview/lib/action_view/template.rb
@@ -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
diff --git a/actionview/test/template/template_test.rb b/actionview/test/template/template_test.rb
index 3dc14e36e0..b348d1f17b 100644
--- a/actionview/test/template/template_test.rb
+++ b/actionview/test/template/template_test.rb
@@ -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