Permalink
Browse files

Ensure expires_in without a :public key sets the Cache-Control header…

… to private. [#2095 state:resolved]

This fixes a regression introduced in f2a32bd, which wasn't exposed due to two
test methods having the same name.

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
  • Loading branch information...
js authored and lifo committed Mar 6, 2009
1 parent fd3ccbe commit c071123b3e2d6fd918dd7e419efe7429355445c2
Showing with 4 additions and 2 deletions.
  1. +3 −1 actionpack/lib/action_controller/base.rb
  2. +1 −1 actionpack/test/controller/render_test.rb
@@ -1205,10 +1205,12 @@ def expires_in(seconds, options = {}) #:doc:
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
@@ -1509,7 +1509,7 @@ def test_expires_in_header
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

0 comments on commit c071123

Please sign in to comment.