aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorRafael França <rafael@franca.dev>2019-07-25 23:49:06 -0400
committerGitHub <noreply@github.com>2019-07-25 23:49:06 -0400
commitf72118577dabd46c939a98437fdb031d9cd9c925 (patch)
tree9673fa18748717359bfd0af137d24b80595a1d6d /actionpack/test
parent72bc0806a7b378cd544e8fbf7ab22d74b7913ffb (diff)
parent6c69ff436acc30d5b3d7c7309feb8bce29330311 (diff)
downloadrails-f72118577dabd46c939a98437fdb031d9cd9c925.tar.gz
rails-f72118577dabd46c939a98437fdb031d9cd9c925.tar.bz2
rails-f72118577dabd46c939a98437fdb031d9cd9c925.zip
Merge pull request #36504 from mtsmfm/mtsmfm/fix-flaky-render-test
Fix flaky test ActionControllerBaseRenderTest#test_direct_render_to_string
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/controller/render_test.rb24
1 files changed, 20 insertions, 4 deletions
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index a2a6c69dd3..dd76824413 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -4,6 +4,11 @@ require "abstract_unit"
require "controller/fake_models"
class TestControllerWithExtraEtags < ActionController::Base
+ self.view_paths = [ActionView::FixtureResolver.new(
+ "test/with_implicit_template.erb" => "Hello explicitly!",
+ "test/hello_world.erb" => "Hello world!"
+ )]
+
def self.controller_name; "test"; end
def self.controller_path; "test"; end
@@ -37,6 +42,11 @@ class TestControllerWithExtraEtags < ActionController::Base
end
class ImplicitRenderTestController < ActionController::Base
+ self.view_paths = [ActionView::FixtureResolver.new(
+ "implicit_render_test/hello_world.erb" => "Hello world!",
+ "implicit_render_test/empty_action_with_template.html.erb" => "<h1>Empty action rendered this implicitly.</h1>\n"
+ )]
+
def empty_action
end
@@ -46,6 +56,10 @@ end
module Namespaced
class ImplicitRenderTestController < ActionController::Base
+ self.view_paths = [ActionView::FixtureResolver.new(
+ "namespaced/implicit_render_test/hello_world.erb" => "Hello world!"
+ )]
+
def hello_world
fresh_when(etag: "abc")
end
@@ -293,13 +307,15 @@ end
module TemplateModificationHelper
private
def modify_template(name)
- path = File.expand_path("../fixtures/#{name}.erb", __dir__)
- original = File.read(path)
- File.write(path, "#{original} Modified!")
+ hash = @controller.view_paths.first.instance_variable_get(:@hash)
+ key = name + ".erb"
+ original = hash[key]
+ hash[key] = "#{original} Modified!"
ActionView::LookupContext::DetailsKey.clear
yield
ensure
- File.write(path, original)
+ hash[key] = original
+ ActionView::LookupContext::DetailsKey.clear
end
end