aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-10-18 14:31:52 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-10-18 14:34:26 -0300
commit90733e70d7d7a41bc7d5b0bebd357dd4950c833e (patch)
treebdf5f9460f85a56643cc390275311b9133f77c17 /railties
parent12fb9372bf75d73481b3323b2c84d1851f5d6304 (diff)
downloadrails-90733e70d7d7a41bc7d5b0bebd357dd4950c833e.tar.gz
rails-90733e70d7d7a41bc7d5b0bebd357dd4950c833e.tar.bz2
rails-90733e70d7d7a41bc7d5b0bebd357dd4950c833e.zip
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.
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/application.rb2
-rw-r--r--railties/test/application/middleware/cache_test.rb14
-rw-r--r--railties/test/application/middleware_test.rb5
3 files changed, 14 insertions, 7 deletions
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!