Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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.
  • Loading branch information...
commit 90733e70d7d7a41bc7d5b0bebd357dd4950c833e 1 parent 12fb937
@rafaelfranca rafaelfranca authored
View
2  railties/lib/rails/application.rb
@@ -286,7 +286,7 @@ def reload_dependencies? #:nodoc:
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
View
14 railties/test/application/middleware/cache_test.rb
@@ -49,8 +49,6 @@ def render_conditionally(headers)
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 @@ def test_cache_is_disabled_in_dev_mode
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 @@ def test_cache_works_with_expires
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 @@ def test_cache_works_with_expires_private
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 @@ def test_cache_works_with_etags
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 @@ def test_cache_works_with_etags_private
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 @@ def test_cache_works_with_last_modified
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"]
View
5 railties/test/application/middleware_test.rb
@@ -57,15 +57,12 @@ def app
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!
Please sign in to comment.
Something went wrong with that request. Please try again.