diff options
author | Javan Makhmali <javan@javan.us> | 2016-06-15 17:56:17 -0400 |
---|---|---|
committer | Javan Makhmali <javan@javan.us> | 2016-06-15 18:25:18 -0400 |
commit | 1ee4eebb2b2da07e49bb7d467f5f9d5497bcf718 (patch) | |
tree | 2cdec002d990d54467a49dcdc3504a4332babe92 /actionview/test | |
parent | 1717836e4fbc111d4b339aff875b2a3c301ab7e3 (diff) | |
download | rails-1ee4eebb2b2da07e49bb7d467f5f9d5497bcf718.tar.gz rails-1ee4eebb2b2da07e49bb7d467f5f9d5497bcf718.tar.bz2 rails-1ee4eebb2b2da07e49bb7d467f5f9d5497bcf718.zip |
Fix finding templates for digesting for */* requests that render a non-default (html) template
Diffstat (limited to 'actionview/test')
3 files changed, 24 insertions, 0 deletions
diff --git a/actionview/test/fixtures/digestor/api/comments/_comments.json.erb b/actionview/test/fixtures/digestor/api/comments/_comments.json.erb new file mode 100644 index 0000000000..c28646a283 --- /dev/null +++ b/actionview/test/fixtures/digestor/api/comments/_comments.json.erb @@ -0,0 +1 @@ +<%= render partial: "comments/comment", collection: commentable.comments %> diff --git a/actionview/test/fixtures/digestor/messages/thread.json.erb b/actionview/test/fixtures/digestor/messages/thread.json.erb new file mode 100644 index 0000000000..e4c1ba97cd --- /dev/null +++ b/actionview/test/fixtures/digestor/messages/thread.json.erb @@ -0,0 +1 @@ +<%= render "comments/comments" %> diff --git a/actionview/test/template/digestor_test.rb b/actionview/test/template/digestor_test.rb index a06f681eda..e39d6ae810 100644 --- a/actionview/test/template/digestor_test.rb +++ b/actionview/test/template/digestor_test.rb @@ -22,6 +22,12 @@ class FixtureFinder < ActionView::LookupContext end end +class ActionView::Digestor::Node + def flatten + [self] + children.flat_map(&:flatten) + end +end + class TemplateDigestorTest < ActionView::TestCase def setup @cwd = Dir.pwd @@ -148,6 +154,17 @@ class TemplateDigestorTest < ActionView::TestCase assert_equal nested_deps, nested_dependencies("messages/show") end + def test_nested_template_deps_with_non_default_rendered_format + finder.rendered_format = nil + nested_deps = [{"comments/comments"=>["comments/comment"]}] + assert_equal nested_deps, nested_dependencies("messages/thread") + end + + def test_template_formats_of_nested_deps_with_non_default_rendered_format + finder.rendered_format = nil + assert_equal [:json, :json, :json], tree_template_formats("messages/thread") + end + def test_recursion_in_renders assert digest("level/recursion") # assert recursion is possible assert_not_nil digest("level/recursion") # assert digest is stored @@ -334,6 +351,11 @@ class TemplateDigestorTest < ActionView::TestCase tree.children.map(&:to_dep_map) end + def tree_template_formats(template_name) + tree = ActionView::Digestor.tree(template_name, finder) + tree.flatten.map(&:template).flat_map(&:formats) + end + def disable_resolver_caching old_caching, ActionView::Resolver.caching = ActionView::Resolver.caching, false yield |