diff options
Diffstat (limited to 'railties/test/application/middleware/cache_test.rb')
-rw-r--r-- | railties/test/application/middleware/cache_test.rb | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/railties/test/application/middleware/cache_test.rb b/railties/test/application/middleware/cache_test.rb index f582ed0e42..050a2161ae 100644 --- a/railties/test/application/middleware/cache_test.rb +++ b/railties/test/application/middleware/cache_test.rb @@ -11,12 +11,16 @@ module ApplicationTests extend Rack::Test::Methods end + def teardown + teardown_app + end + def simple_controller controller :expires, <<-RUBY class ExpiresController < ApplicationController def expires_header expires_in 10, :public => !params[:private] - render :text => ActiveSupport::SecureRandom.hex(16) + render :text => SecureRandom.hex(16) end def expires_etag @@ -27,10 +31,14 @@ module ApplicationTests $last_modified ||= Time.now.utc render_conditionally(:last_modified => $last_modified) end + + def keeps_if_modified_since + render :text => request.headers['If-Modified-Since'] + end private def render_conditionally(headers) if stale?(headers.merge(:public => !params[:private])) - render :text => ActiveSupport::SecureRandom.hex(16) + render :text => SecureRandom.hex(16) end end end @@ -43,6 +51,16 @@ module ApplicationTests RUBY end + def test_cache_keeps_if_modified_since + simple_controller + expected = "Wed, 30 May 1984 19:43:31 GMT" + + get "/expires/keeps_if_modified_since", {}, "HTTP_IF_MODIFIED_SINCE" => expected + + assert_equal 200, last_response.status + assert_equal expected, last_response.body, "cache should have kept If-Modified-Since" + end + def test_cache_is_disabled_in_dev_mode simple_controller app("development") |