diff options
author | Fabrizio Regini <freegenie@gmail.com> | 2012-11-29 16:16:18 +0100 |
---|---|---|
committer | Fabrizio Regini <freegenie@gmail.com> | 2012-12-05 14:58:38 +0100 |
commit | 6b014a4580a8f17ebb73b441e029c0bb7d34a8c5 (patch) | |
tree | a9f295db53729358accbeb047fe1d0be55e87060 /actionpack/test/controller | |
parent | e905639af2fe947ff7e1e2331e9216032dff8b3e (diff) | |
download | rails-6b014a4580a8f17ebb73b441e029c0bb7d34a8c5.tar.gz rails-6b014a4580a8f17ebb73b441e029c0bb7d34a8c5.tar.bz2 rails-6b014a4580a8f17ebb73b441e029c0bb7d34a8c5.zip |
Allow fragment cache to accept :if and :unless options
[Stephen Ausman + Fabrizio Regini]
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/log_subscriber_test.rb | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/actionpack/test/controller/log_subscriber_test.rb b/actionpack/test/controller/log_subscriber_test.rb index 7b4d49be20..d8b971f963 100644 --- a/actionpack/test/controller/log_subscriber_test.rb +++ b/actionpack/test/controller/log_subscriber_test.rb @@ -46,6 +46,22 @@ module Another render :inline => "<%= cache('foo%bar'){ 'Contains % sign in key' } %>" end + def with_fragment_cache_and_if_true_condition + render :inline => "<%= cache('foo', :if => true) { 'bar' } %>" + end + + def with_fragment_cache_and_if_false_condition + render :inline => "<%= cache('foo', :if => false) { 'bar' } %>" + end + + def with_fragment_cache_and_unless_false_condition + render :inline => "<%= cache('foo', :unless => false) { 'bar' } %>" + end + + def with_fragment_cache_and_unless_true_condition + render :inline => "<%= cache('foo', :unless => true) { 'bar' } %>" + end + def with_exception raise Exception end @@ -203,6 +219,54 @@ class ACLogSubscriberTest < ActionController::TestCase @controller.config.perform_caching = true end + def test_with_fragment_cache_and_if_true + @controller.config.perform_caching = true + get :with_fragment_cache_and_if_true_condition + wait + + assert_equal 4, logs.size + 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_if_false + @controller.config.perform_caching = true + get :with_fragment_cache_and_if_false_condition + wait + + assert_equal 2, logs.size + assert_no_match(/Read fragment views\/foo/, logs[1]) + assert_no_match(/Write fragment views\/foo/, logs[2]) + ensure + @controller.config.perform_caching = true + end + + def test_with_fragment_cache_and_unless_true + @controller.config.perform_caching = true + get :with_fragment_cache_and_unless_true_condition + wait + + assert_equal 2, logs.size + assert_no_match(/Read fragment views\/foo/, logs[1]) + assert_no_match(/Write fragment views\/foo/, logs[2]) + ensure + @controller.config.perform_caching = true + end + + def test_with_fragment_cache_and_unless_false + @controller.config.perform_caching = true + get :with_fragment_cache_and_unless_false_condition + wait + + assert_equal 4, logs.size + 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 |