From fe698bad34dbb11679c6951132bb46375b4ad8af Mon Sep 17 00:00:00 2001 From: "Ryan T. Hosford" Date: Sat, 13 Feb 2016 03:28:05 -0600 Subject: adds tests for Digestor#nested_dependencies --- actionview/test/fixtures/digestor/messages/peek.html.erb | 2 ++ actionview/test/template/digestor_test.rb | 10 ++++++++++ 2 files changed, 12 insertions(+) create mode 100644 actionview/test/fixtures/digestor/messages/peek.html.erb (limited to 'actionview/test') diff --git a/actionview/test/fixtures/digestor/messages/peek.html.erb b/actionview/test/fixtures/digestor/messages/peek.html.erb new file mode 100644 index 0000000000..84885ab0bc --- /dev/null +++ b/actionview/test/fixtures/digestor/messages/peek.html.erb @@ -0,0 +1,2 @@ +<%# Template Dependency: messages/message %> +<%= render "comments/comments" %> diff --git a/actionview/test/template/digestor_test.rb b/actionview/test/template/digestor_test.rb index bfab97cf1e..e50caac6d8 100644 --- a/actionview/test/template/digestor_test.rb +++ b/actionview/test/template/digestor_test.rb @@ -130,6 +130,16 @@ class TemplateDigestorTest < ActionView::TestCase end end + def test_getting_of_singly_nested_dependencies + singly_nested_dependencies = ["messages/header", "messages/form", "messages/message", "events/event", "comments/comment"] + assert_equal singly_nested_dependencies, nested_dependencies('messages/edit') + end + + def test_getting_of_doubly_nested_dependencies + doubly_nested = [{"comments/comments"=>["comments/comment"]}, "messages/message"] + assert_equal doubly_nested, nested_dependencies('messages/peek') + end + def test_nested_template_directory assert_digest_difference("messages/show") do change_template("messages/actions/_move") -- cgit v1.2.3 From 3239ed48d28f3c0baf4445e6c279107e892b7cab Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 18 Feb 2016 08:23:26 -0800 Subject: move digest cache on to the DetailsKey object This moves digest calculation cache on to the details key object. Before, the digest cache was a class level ivar, and one of the keys was the hash value of the details key object: https://github.com/rails/rails/blob/13c4cc3b5aea02716b7459c0da641438077f5236/actionview/lib/action_view/digestor.rb#L28 An object's hash value is not unique, so it's possible for this cache key to produce colliding keys with no resolution. This commit move cache on to the details key object itself, so we know that the digests are always unique per details key object. --- actionview/test/template/digestor_test.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'actionview/test') diff --git a/actionview/test/template/digestor_test.rb b/actionview/test/template/digestor_test.rb index e50caac6d8..9ff5f7126b 100644 --- a/actionview/test/template/digestor_test.rb +++ b/actionview/test/template/digestor_test.rb @@ -33,7 +33,6 @@ class TemplateDigestorTest < ActionView::TestCase def teardown Dir.chdir @cwd FileUtils.rm_r @tmp_dir - ActionView::Digestor.cache.clear end def test_top_level_change_reflected @@ -301,12 +300,12 @@ class TemplateDigestorTest < ActionView::TestCase def assert_digest_difference(template_name, options = {}) previous_digest = digest(template_name, options) - ActionView::Digestor.cache.clear + finder.digest_cache.clear yield assert_not_equal previous_digest, digest(template_name, options), "digest didn't change" - ActionView::Digestor.cache.clear + finder.digest_cache.clear end def digest(template_name, options = {}) -- cgit v1.2.3