1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix digesting templates with mixed formats

This commit is contained in:
Javan Makhmali 2018-03-18 09:59:47 -04:00
parent 9d9f752661
commit f4eb2e23a8
3 changed files with 15 additions and 4 deletions

View file

@ -45,11 +45,9 @@ module ActionView
# Create a dependency tree for template named +name+.
def tree(name, finder, partial = false, seen = {})
logical_name = name.gsub(%r|/_|, "/")
finder.formats = [finder.rendered_format] if finder.rendered_format
options = {}
options[:formats] = [finder.rendered_format] if finder.rendered_format
if template = finder.disable_cache { finder.find_all(logical_name, [], partial, [], options).first }
if template = finder.disable_cache { finder.find_all(logical_name, [], partial, []).first }
finder.rendered_format ||= template.formats.first
if node = seen[template.identifier] # handle cycles in the tree

View file

@ -0,0 +1 @@
alert("<%=j render("comments/comment") %>")

View file

@ -160,6 +160,18 @@ class TemplateDigestorTest < ActionView::TestCase
assert_equal [:html], tree_template_formats("messages/show").uniq
end
def test_template_dependencies_with_fallback_from_js_to_html_format
finder.rendered_format = :js
assert_equal ["comments/comment"], dependencies("comments/show")
end
def test_template_digest_with_fallback_from_js_to_html_format
finder.rendered_format = :js
assert_digest_difference("comments/show") do
change_template("comments/_comment")
end
end
def test_recursion_in_renders
assert digest("level/recursion") # assert recursion is possible
assert_not_nil digest("level/recursion") # assert digest is stored