From c9397e684c081ce7245efcfa7962f03203574f36 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 8 Jun 2007 05:01:35 +0000 Subject: Action caching is limited to GET requests returning 200 OK status. Closes #3335. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6970 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/controller/caching_test.rb | 31 ++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'actionpack/test/controller/caching_test.rb') diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index 0dc73472cf..29fa0074f7 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -121,7 +121,7 @@ end class ActionCachingTestController < ActionController::Base - caches_action :index + caches_action :index, :redirected, :forbidden caches_action :show, :cache_path => 'http://test.host/custom/show' caches_action :edit, :cache_path => Proc.new { |c| c.params[:id] ? "http://test.host/#{c.params[:id]};edit" : "http://test.host/edit" } @@ -129,7 +129,16 @@ class ActionCachingTestController < ActionController::Base @cache_this = Time.now.to_f.to_s render :text => @cache_this end - + + def redirected + redirect_to :action => 'index' + end + + def forbidden + render :text => "Forbidden" + headers["Status"] = "403 Forbidden" + end + alias_method :show, :index alias_method :edit, :index @@ -245,6 +254,24 @@ class ActionCacheTest < Test::Unit::TestCase assert_equal david_cache, @response.body end + def test_redirect_is_not_cached + get :redirected + assert_response :redirect + reset! + + get :redirected + assert_response :redirect + end + + def test_forbidden_is_not_cached + get :forbidden + assert_response :forbidden + reset! + + get :forbidden + assert_response :forbidden + end + def test_xml_version_of_resource_is_treated_as_different_cache @mock_controller.mock_url_for = 'http://example.org/posts/' @mock_controller.mock_path = '/posts/index.xml' -- cgit v1.2.3