未验证 提交 393b8640 编写于 作者: R Rafael França 提交者: Rafael Mendonça França

Merge pull request #36504 from mtsmfm/mtsmfm/fix-flaky-render-test

Fix flaky test ActionControllerBaseRenderTest#test_direct_render_to_string
上级 b2835f72
......@@ -4,6 +4,11 @@
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 @@ def with_implicit_template
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 @@ def empty_action_with_template
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
......@@ -294,13 +308,15 @@ def determine_layout
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册