From 90733e70d7d7a41bc7d5b0bebd357dd4950c833e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Thu, 18 Oct 2012 14:31:52 -0300 Subject: Don't use action_controller.perform_caching to enable rack-rack. Setting the action_dispatch.rack_cache options to true or a hash should be the way to enable it. --- railties/lib/rails/application.rb | 2 +- railties/test/application/middleware/cache_test.rb | 14 ++++++++++++-- railties/test/application/middleware_test.rb | 5 +---- 3 files changed, 14 insertions(+), 7 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index eff5bbbdd6..9ef001c7d0 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -286,7 +286,7 @@ module Rails def default_middleware_stack #:nodoc: ActionDispatch::MiddlewareStack.new.tap do |middleware| app = self - if rack_cache = config.action_controller.perform_caching && config.action_dispatch.rack_cache + if rack_cache = config.action_dispatch.rack_cache begin require 'rack/cache' rescue LoadError => error diff --git a/railties/test/application/middleware/cache_test.rb b/railties/test/application/middleware/cache_test.rb index 9b6c76e7aa..c99666d7e4 100644 --- a/railties/test/application/middleware/cache_test.rb +++ b/railties/test/application/middleware/cache_test.rb @@ -49,8 +49,6 @@ module ApplicationTests get ':controller(/:action)' end RUBY - - add_to_config "config.action_dispatch.rack_cache = true" end def test_cache_keeps_if_modified_since @@ -80,6 +78,8 @@ module ApplicationTests def test_cache_works_with_expires simple_controller + add_to_config "config.action_dispatch.rack_cache = true" + get "/expires/expires_header" assert_equal "miss, store", last_response.headers["X-Rack-Cache"] assert_equal "max-age=10, public", last_response.headers["Cache-Control"] @@ -96,6 +96,8 @@ module ApplicationTests def test_cache_works_with_expires_private simple_controller + add_to_config "config.action_dispatch.rack_cache = true" + get "/expires/expires_header", private: true assert_equal "miss", last_response.headers["X-Rack-Cache"] assert_equal "private, max-age=10", last_response.headers["Cache-Control"] @@ -110,6 +112,8 @@ module ApplicationTests def test_cache_works_with_etags simple_controller + add_to_config "config.action_dispatch.rack_cache = true" + get "/expires/expires_etag" assert_equal "miss, store", last_response.headers["X-Rack-Cache"] assert_equal "public", last_response.headers["Cache-Control"] @@ -125,6 +129,8 @@ module ApplicationTests def test_cache_works_with_etags_private simple_controller + add_to_config "config.action_dispatch.rack_cache = true" + get "/expires/expires_etag", private: true assert_equal "miss", last_response.headers["X-Rack-Cache"] assert_equal "must-revalidate, private, max-age=0", last_response.headers["Cache-Control"] @@ -140,6 +146,8 @@ module ApplicationTests def test_cache_works_with_last_modified simple_controller + add_to_config "config.action_dispatch.rack_cache = true" + get "/expires/expires_last_modified" assert_equal "miss, store", last_response.headers["X-Rack-Cache"] assert_equal "public", last_response.headers["Cache-Control"] @@ -155,6 +163,8 @@ module ApplicationTests def test_cache_works_with_last_modified_private simple_controller + add_to_config "config.action_dispatch.rack_cache = true" + get "/expires/expires_last_modified", private: true assert_equal "miss", last_response.headers["X-Rack-Cache"] assert_equal "must-revalidate, private, max-age=0", last_response.headers["Cache-Control"] diff --git a/railties/test/application/middleware_test.rb b/railties/test/application/middleware_test.rb index c03d35e926..c5a0d02fe1 100644 --- a/railties/test/application/middleware_test.rb +++ b/railties/test/application/middleware_test.rb @@ -57,15 +57,12 @@ module ApplicationTests end test "Rack::Cache is not included by default" do - add_to_config "config.action_controller.perform_caching = true" - boot! assert !middleware.include?("Rack::Cache"), "Rack::Cache is not included in the default stack unless you set config.action_dispatch.rack_cache" end - test "Rack::Cache is present when action_controller.perform_caching is set and action_dispatch.rack_cache is set" do - add_to_config "config.action_controller.perform_caching = true" + test "Rack::Cache is present when action_dispatch.rack_cache is set" do add_to_config "config.action_dispatch.rack_cache = true" boot! -- cgit v1.2.3