diff options
author | Christos Trochalakis <yatiohi@ideopolis.gr> | 2010-09-16 19:44:18 +0300 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-18 09:52:11 -0800 |
commit | 7dab186fded971e69f9d8bf5db524c20da326b83 (patch) | |
tree | 4d28f7fa1e1ab8f86614d056baa0c53bf726ec9f /actionpack | |
parent | 11fe2161ce8adc39aa69178211f7b661eafb201a (diff) | |
download | rails-7dab186fded971e69f9d8bf5db524c20da326b83.tar.gz rails-7dab186fded971e69f9d8bf5db524c20da326b83.tar.bz2 rails-7dab186fded971e69f9d8bf5db524c20da326b83.zip |
Issue one Cache#read command instead of two in the case of a fragment cache hit
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_view/helpers/cache_helper.rb | 4 | ||||
-rw-r--r-- | actionpack/test/controller/log_subscriber_test.rb | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/actionpack/lib/action_view/helpers/cache_helper.rb b/actionpack/lib/action_view/helpers/cache_helper.rb index 30e6c078b1..385378ea29 100644 --- a/actionpack/lib/action_view/helpers/cache_helper.rb +++ b/actionpack/lib/action_view/helpers/cache_helper.rb @@ -44,8 +44,8 @@ module ActionView private # TODO: Create an object that has caching read/write on it def fragment_for(name = {}, options = nil, &block) #:nodoc: - if controller.fragment_exist?(name, options) - controller.read_fragment(name, options) + if fragment = controller.read_fragment(name, options) + fragment else # VIEW TODO: Make #capture usable outside of ERB # This dance is needed because Builder can't use capture diff --git a/actionpack/test/controller/log_subscriber_test.rb b/actionpack/test/controller/log_subscriber_test.rb index e6fe0b1f04..cac0881133 100644 --- a/actionpack/test/controller/log_subscriber_test.rb +++ b/actionpack/test/controller/log_subscriber_test.rb @@ -139,20 +139,20 @@ class ACLogSubscriberTest < ActionController::TestCase wait assert_equal 4, logs.size - assert_match(/Exist fragment\? views\/foo/, logs[1]) + assert_match /Read fragment views\/foo/, logs[1] assert_match(/Write fragment views\/foo/, logs[2]) ensure @controller.config.perform_caching = true end - + def test_with_fragment_cache_and_percent_in_key @controller.config.perform_caching = true get :with_fragment_cache_and_percent_in_key wait assert_equal 4, logs.size - assert_match(/Exist fragment\? views\/foo%bar/, logs[1]) - assert_match(/Write fragment views\/foo%bar/, logs[2]) + assert_match /Read fragment views\/foo/, logs[1] + assert_match /Write fragment views\/foo/, logs[2] ensure @controller.config.perform_caching = true end |