From efcfce50c417975ee038a107755a1542a690d39b Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Sat, 8 Aug 2009 12:46:44 -0300 Subject: Fixes "Cached fragment hit" written to log even if fragment is not cached (Erik Andrejko) [#2917 state:resolved] --- actionpack/test/controller/caching_test.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'actionpack/test/controller/caching_test.rb') diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index c286976315..68529cc8f7 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -625,6 +625,21 @@ class FragmentCachingTest < ActionController::TestCase assert !fragment_computed assert_equal 'generated till now -> fragment content', buffer end + + def test_fragment_for_logging + fragment_computed = false + + @controller.class.expects(:benchmark).with('Cached fragment exists?: views/expensive') + @controller.class.expects(:benchmark).with('Cached fragment miss: views/expensive') + @controller.class.expects(:benchmark).with('Cached fragment hit: views/expensive').never + + buffer = 'generated till now -> ' + @controller.fragment_for(buffer, 'expensive') { fragment_computed = true } + + assert fragment_computed + assert_equal 'generated till now -> ', buffer + end + end class FunctionalCachingController < ActionController::Base -- cgit v1.2.3