diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-06-08 05:01:35 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-06-08 05:01:35 +0000 |
commit | c9397e684c081ce7245efcfa7962f03203574f36 (patch) | |
tree | 3425732b6df033fc41fc9c27fb61f29fd2a37e69 /actionpack/test/controller | |
parent | cd9d1711daaa93b8dc589f80693ee9eb7d3dfce5 (diff) | |
download | rails-c9397e684c081ce7245efcfa7962f03203574f36.tar.gz rails-c9397e684c081ce7245efcfa7962f03203574f36.tar.bz2 rails-c9397e684c081ce7245efcfa7962f03203574f36.zip |
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
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/caching_test.rb | 31 |
1 files changed, 29 insertions, 2 deletions
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' |