aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2019-06-06 11:23:31 -0700
committerGitHub <noreply@github.com>2019-06-06 11:23:31 -0700
commit1126d14c144c79745779496f39640ce066b95d1d (patch)
tree22fd8b7c30619b6e7ed3ce711588c316832f8a4e /actionview/test
parentcb9c1da6952628801cfc7323ca5b8193bda5b294 (diff)
parentdf4ab6e1037361a5cddff33ac725a27595f19438 (diff)
downloadrails-1126d14c144c79745779496f39640ce066b95d1d.tar.gz
rails-1126d14c144c79745779496f39640ce066b95d1d.tar.bz2
rails-1126d14c144c79745779496f39640ce066b95d1d.zip
Merge pull request #36422 from jhawthorn/parallelize_actionview
Run actionview tests in parallel
Diffstat (limited to 'actionview/test')
-rw-r--r--actionview/test/abstract_unit.rb2
-rw-r--r--actionview/test/active_record_unit.rb10
-rw-r--r--actionview/test/template/compiled_templates_test.rb40
3 files changed, 13 insertions, 39 deletions
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
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