diff options
author | Javan Makhmali <javan@javan.us> | 2018-03-18 09:59:47 -0400 |
---|---|---|
committer | Javan Makhmali <javan@javan.us> | 2018-03-20 06:33:20 -0400 |
commit | f4eb2e23a8f61e2766fb32a134bfa6d6b3b7f512 (patch) | |
tree | 6530dc71dbb67bbad5dc799f0a698c5573f2724b | |
parent | 9d9f752661c31b3063d55bec14e797c957d2bb7d (diff) | |
download | rails-f4eb2e23a8f61e2766fb32a134bfa6d6b3b7f512.tar.gz rails-f4eb2e23a8f61e2766fb32a134bfa6d6b3b7f512.tar.bz2 rails-f4eb2e23a8f61e2766fb32a134bfa6d6b3b7f512.zip |
Fix digesting templates with mixed formats
-rw-r--r-- | actionview/lib/action_view/digestor.rb | 6 | ||||
-rw-r--r-- | actionview/test/fixtures/digestor/comments/show.js.erb | 1 | ||||
-rw-r--r-- | actionview/test/template/digestor_test.rb | 12 |
3 files changed, 15 insertions, 4 deletions
diff --git a/actionview/lib/action_view/digestor.rb b/actionview/lib/action_view/digestor.rb index 1cf0bd3016..dbd7a4ee11 100644 --- a/actionview/lib/action_view/digestor.rb +++ b/actionview/lib/action_view/digestor.rb @@ -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 diff --git a/actionview/test/fixtures/digestor/comments/show.js.erb b/actionview/test/fixtures/digestor/comments/show.js.erb new file mode 100644 index 0000000000..38b37dfa2b --- /dev/null +++ b/actionview/test/fixtures/digestor/comments/show.js.erb @@ -0,0 +1 @@ +alert("<%=j render("comments/comment") %>") diff --git a/actionview/test/template/digestor_test.rb b/actionview/test/template/digestor_test.rb index 1bfa39a319..ddaa7febb3 100644 --- a/actionview/test/template/digestor_test.rb +++ b/actionview/test/template/digestor_test.rb @@ -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 |