From df4ab6e1037361a5cddff33ac725a27595f19438 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Wed, 5 Jun 2019 17:56:31 -0700 Subject: [PATCH] Run actionview tests in parallel --- actionview/test/abstract_unit.rb | 2 ++ actionview/test/active_record_unit.rb | 10 ++++++++++ 2 files changed, 12 insertions(+) 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