aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Sørensen <johan@johansorensen.com>2009-03-06 10:17:20 +0100
committerPratik Naik <pratiknaik@gmail.com>2009-03-07 12:18:10 +0000
commitc071123b3e2d6fd918dd7e419efe7429355445c2 (patch)
treef8156ec917b02b0c803d77f2c0954d9b3192161a
parentfd3ccbe955ed58298df43f537a01358d15d8d4cf (diff)
downloadrails-c071123b3e2d6fd918dd7e419efe7429355445c2.tar.gz
rails-c071123b3e2d6fd918dd7e419efe7429355445c2.tar.bz2
rails-c071123b3e2d6fd918dd7e419efe7429355445c2.zip
Ensure expires_in without a :public key sets the Cache-Control header to private. [#2095 state:resolved]
This fixes a regression introduced in f2a32bd0, which wasn't exposed due to two test methods having the same name. Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
-rw-r--r--actionpack/lib/action_controller/base.rb4
-rw-r--r--actionpack/test/controller/render_test.rb2
2 files changed, 4 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 5da47ce317..9d06d052b4 100644
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -1205,10 +1205,12 @@ module ActionController #:nodoc:
cache_control = response.headers["Cache-Control"].split(",").map {|k| k.strip }
cache_control << "max-age=#{seconds}"
+ cache_control.delete("no-cache")
if options[:public]
cache_control.delete("private")
- cache_control.delete("no-cache")
cache_control << "public"
+ else
+ cache_control << "private"
end
# This allows for additional headers to be passed through like 'max-stale' => 5.hours
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index 02ae8ac942..2f4cc5a615 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -1509,7 +1509,7 @@ class ExpiresInRenderTest < ActionController::TestCase
assert_equal "max-age=60, private", @response.headers["Cache-Control"]
end
- def test_expires_in_header
+ def test_expires_in_header_with_public
get :conditional_hello_with_expires_in_with_public
assert_equal "max-age=60, public", @response.headers["Cache-Control"]
end