aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view
diff options
context:
space:
mode:
authorStan Lo <a22301613@yahoo.com.tw>2017-04-02 00:24:03 +0800
committerKasper Timm Hansen <kaspth@gmail.com>2017-06-08 21:42:46 +0200
commit2abf6ca0c8304a3cfcdae6e14060b561780be43c (patch)
tree189b1f287e37b3c79ad2056ca659e8733fe88491 /actionview/lib/action_view
parentf1e42fe267342ffa4cea84cf09b0caaee733632c (diff)
downloadrails-2abf6ca0c8304a3cfcdae6e14060b561780be43c.tar.gz
rails-2abf6ca0c8304a3cfcdae6e14060b561780be43c.tar.bz2
rails-2abf6ca0c8304a3cfcdae6e14060b561780be43c.zip
Use a hash to record every partial's cache hit status instead of sharing a boolean.
Diffstat (limited to 'actionview/lib/action_view')
-rw-r--r--actionview/lib/action_view/base.rb1
-rw-r--r--actionview/lib/action_view/helpers/cache_helper.rb6
-rw-r--r--actionview/lib/action_view/renderer/partial_renderer.rb2
3 files changed, 6 insertions, 3 deletions
diff --git a/actionview/lib/action_view/base.rb b/actionview/lib/action_view/base.rb
index 37f0dd1ee4..1808553239 100644
--- a/actionview/lib/action_view/base.rb
+++ b/actionview/lib/action_view/base.rb
@@ -202,6 +202,7 @@ module ActionView #:nodoc:
@view_renderer = ActionView::Renderer.new(lookup_context)
end
+ @cache_hit = {}
assign(assigns)
assign_controller(controller)
_prepare_context
diff --git a/actionview/lib/action_view/helpers/cache_helper.rb b/actionview/lib/action_view/helpers/cache_helper.rb
index c3aecadcd6..dfa0956fe2 100644
--- a/actionview/lib/action_view/helpers/cache_helper.rb
+++ b/actionview/lib/action_view/helpers/cache_helper.rb
@@ -235,11 +235,13 @@ module ActionView
end
def fragment_for(name = {}, options = nil, &block)
+ # Some tests might using this helper without initialize actionview object
+ @cache_hit ||= {}
if content = read_fragment_for(name, options)
- @cache_hit = true
+ @cache_hit[@virtual_path] = true
content
else
- @cache_hit = false
+ @cache_hit[@virtual_path] = false
write_fragment_for(name, options, &block)
end
end
diff --git a/actionview/lib/action_view/renderer/partial_renderer.rb b/actionview/lib/action_view/renderer/partial_renderer.rb
index 647b15ea94..797db34fb8 100644
--- a/actionview/lib/action_view/renderer/partial_renderer.rb
+++ b/actionview/lib/action_view/renderer/partial_renderer.rb
@@ -344,7 +344,7 @@ module ActionView
end
content = layout.render(view, locals) { content } if layout
- payload[:cache_hit] = view.cache_hit
+ payload[:cache_hit] = !!view.cache_hit[@template.virtual_path]
content
end
end