Merge pull request #42437 from HParker/digest-find-parent-controller-template

Use the lookup_context to find the correct template path
This commit is contained in:
Rafael França 2021-06-23 13:59:09 -04:00 committed by GitHub
commit ec6935606e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 1 deletions

View File

@ -44,7 +44,7 @@ module ActionController
# template digest from the ETag.
def pick_template_for_etag(options)
unless options[:template] == false
options[:template] || "#{controller_path}/#{action_name}"
options[:template] || lookup_context.find_all(action_name, _prefixes).first&.virtual_path
end
end

View File

@ -65,6 +65,12 @@ module Namespaced
end
end
class InheritedRenderTestController < ImplicitRenderTestController
def hello_world
fresh_when(etag: "abc")
end
end
class TestController < ActionController::Base
protect_from_forgery
@ -724,6 +730,28 @@ class NamespacedEtagRenderTest < ActionController::TestCase
end
end
class InheritedEtagRenderTest < ActionController::TestCase
tests InheritedRenderTestController
include TemplateModificationHelper
def test_etag_reflects_template_digest
get :hello_world
assert_response :ok
assert_not_nil etag = @response.etag
request.if_none_match = etag
get :hello_world
assert_response :not_modified
modify_template("implicit_render_test/hello_world") do
request.if_none_match = etag
get :hello_world
assert_response :ok
assert_not_equal etag, @response.etag
end
end
end
class MetalRenderTest < ActionController::TestCase
tests MetalTestController