From d130ea2ff2f51dd1c53b2fb70305d71aad261c5d Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Wed, 5 Jun 2019 18:22:04 -0700 Subject: Remove actionview tests which modify fixtures We shouldn't modify fixtures (or any files which are checked-in). It prevents us from parallelizing, and probably has other issues. We could fix these tests by copying the file to a tmpdir and modifying it there, but I don't think they are testing anything useful anymore. Re-initializing a resolver isn't representative of "uncached" rendering (either in dev-mode or using lookup_context.disable_cache). --- .../test/template/compiled_templates_test.rb | 40 +--------------------- 1 file changed, 1 insertion(+), 39 deletions(-) (limited to 'actionview/test') diff --git a/actionview/test/template/compiled_templates_test.rb b/actionview/test/template/compiled_templates_test.rb index d7f2e8ee07..59fa058bed 100644 --- a/actionview/test/template/compiled_templates_test.rb +++ b/actionview/test/template/compiled_templates_test.rb @@ -60,46 +60,8 @@ class CompiledTemplatesTest < ActiveSupport::TestCase assert_equal "two", render(template: "test/render_file_with_locals_and_default", locals: { secret: "two" }) end - def test_template_changes_are_not_reflected_with_cached_templates - assert_equal "Hello world!", render(template: "test/hello_world") - modify_template "test/hello_world.erb", "Goodbye world!" do - assert_equal "Hello world!", render(template: "test/hello_world") - end - assert_equal "Hello world!", render(template: "test/hello_world") - end - - def test_template_changes_are_reflected_with_uncached_templates - assert_equal "Hello world!", render_without_cache(template: "test/hello_world") - modify_template "test/hello_world.erb", "Goodbye world!" do - assert_equal "Goodbye world!", render_without_cache(template: "test/hello_world") - end - assert_equal "Hello world!", render_without_cache(template: "test/hello_world") - end - private def render(*args) - render_with_cache(*args) - end - - def render_with_cache(*args) - view_paths = ActionController::Base.view_paths - view_class.with_view_paths(view_paths, {}).render(*args) - end - - def render_without_cache(*args) - path = ActionView::FileSystemResolver.new(FIXTURE_LOAD_PATH) - view_paths = ActionView::PathSet.new([path]) - view_class.with_view_paths(view_paths, {}).render(*args) - end - - def modify_template(template, content) - filename = "#{FIXTURE_LOAD_PATH}/#{template}" - old_content = File.read(filename) - begin - File.open(filename, "wb+") { |f| f.write(content) } - yield - ensure - File.open(filename, "wb+") { |f| f.write(old_content) } - end + ActionController::Base.render(*args) end end -- cgit v1.2.3 From df4ab6e1037361a5cddff33ac725a27595f19438 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Wed, 5 Jun 2019 17:56:31 -0700 Subject: Run actionview tests in parallel --- actionview/test/abstract_unit.rb | 2 ++ actionview/test/active_record_unit.rb | 10 ++++++++++ 2 files changed, 12 insertions(+) (limited to 'actionview/test') diff --git a/actionview/test/abstract_unit.rb b/actionview/test/abstract_unit.rb index 2c1b277b41..b652f2e6cb 100644 --- a/actionview/test/abstract_unit.rb +++ b/actionview/test/abstract_unit.rb @@ -192,6 +192,8 @@ module ActionDispatch end class ActiveSupport::TestCase + parallelize + include ActiveSupport::Testing::MethodCallAssertions private diff --git a/actionview/test/active_record_unit.rb b/actionview/test/active_record_unit.rb index e4ea6a426d..4efb31a360 100644 --- a/actionview/test/active_record_unit.rb +++ b/actionview/test/active_record_unit.rb @@ -42,6 +42,12 @@ class ActiveRecordTestConnector self.able_to_connect = false end + def reconnect + return unless able_to_connect + ActiveRecord::Base.connection.reconnect! + load_schema + end + private def setup_connection if Object.const_defined?(:ActiveRecord) @@ -102,3 +108,7 @@ class ActiveRecordTestCase < ActionController::TestCase end ActiveRecordTestConnector.setup + +ActiveSupport::Testing::Parallelization.after_fork_hook do + ActiveRecordTestConnector.reconnect +end -- cgit v1.2.3