diff options
Diffstat (limited to 'railties/test/application/middleware/cache_test.rb')
-rw-r--r-- | railties/test/application/middleware/cache_test.rb | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/railties/test/application/middleware/cache_test.rb b/railties/test/application/middleware/cache_test.rb index 9b6c76e7aa..b4db840e68 100644 --- a/railties/test/application/middleware/cache_test.rb +++ b/railties/test/application/middleware/cache_test.rb @@ -45,12 +45,10 @@ module ApplicationTests RUBY app_file 'config/routes.rb', <<-RUBY - AppTemplate::Application.routes.draw do + Rails.application.routes.draw do get ':controller(/:action)' end RUBY - - add_to_config "config.action_dispatch.rack_cache = true" end def test_cache_keeps_if_modified_since @@ -80,9 +78,11 @@ 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"] + assert_equal "miss, ignore, store", last_response.headers["X-Rack-Cache"] + assert_equal "max-age=10, public", last_response.headers["Cache-Control"] body = last_response.body @@ -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,9 +112,11 @@ 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"] + assert_equal "miss, ignore, store", last_response.headers["X-Rack-Cache"] + assert_equal "public", last_response.headers["Cache-Control"] body = last_response.body etag = last_response.headers["ETag"] @@ -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,9 +146,11 @@ 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"] + assert_equal "miss, ignore, store", last_response.headers["X-Rack-Cache"] + assert_equal "public", last_response.headers["Cache-Control"] body = last_response.body last = last_response.headers["Last-Modified"] @@ -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"] |