From f5bdda6bd84267401a9b8dcd3aec52ad448524a7 Mon Sep 17 00:00:00 2001 From: Chetan Sarva Date: Mon, 12 Apr 2010 23:03:17 -0400 Subject: [PATCH 1/2] Apply config option config.action_controller.perform_caching [#4383 state:resolved] --- actionpack/lib/action_controller/railtie.rb | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/actionpack/lib/action_controller/railtie.rb b/actionpack/lib/action_controller/railtie.rb index b029434..79034ea 100644 --- a/actionpack/lib/action_controller/railtie.rb +++ b/actionpack/lib/action_controller/railtie.rb @@ -84,5 +84,9 @@ module ActionController proxy = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(app.routes, message) ActionController::Routing::Routes = proxy end + + initializer "action_controller.perform_caching" do |app| + ActiveSupport.on_load(:action_controller) { self.perform_caching = app.config.action_controller.perform_caching } + end end end \ No newline at end of file -- 1.6.5 From 9881c5397d10140b87646a15378538273390b5f5 Mon Sep 17 00:00:00 2001 From: Chetan Sarva Date: Tue, 13 Apr 2010 11:30:48 -0400 Subject: [PATCH 2/2] Added tests for config.action_controller.perform_caching [#4383 state:resolved] --- railties/test/application/configuration_test.rb | 36 +++++++++++++++++++++++ 1 files changed, 36 insertions(+), 0 deletions(-) diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 8bf0f09..4447c72 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -285,5 +285,41 @@ module ApplicationTests get "/" assert last_response.body =~ /csrf\-param/ end + + test "config.action_controller.perform_caching = true" do + make_basic_app do |app| + app.config.action_controller.perform_caching = true + end + + class ::OmgController < ActionController::Base + caches_action :index + def index + render :text => rand(1000) + end + end + + get "/" + res = last_response.body + get "/" + assert_equal res, last_response.body # value should be unchanged + end + + test "config.action_controller.perform_caching = false" do + make_basic_app do |app| + app.config.action_controller.perform_caching = false + end + + class ::OmgController < ActionController::Base + caches_action :index + def index + render :text => rand(1000) + end + end + + get "/" + res = last_response.body + get "/" + assert_not_equal res, last_response.body + end end end -- 1.6.5