提交 90733e70 编写于 作者: R Rafael Mendonça França

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.
上级 12fb9372
......@@ -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
......
......@@ -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"]
......
......@@ -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!
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册