Permalink
Browse files

Deleting and setting a cookie in the same request was broken

Made sure to remove a cookie from @deleted_cookies when set

[#4211 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information...
1 parent 0e15f07 commit c8dd6f224c9345b7e95cc0203b636e49412b71dc Mathias Biilmann Christensen committed with jeremy Mar 18, 2010
Showing with 12 additions and 0 deletions.
  1. +1 −0 actionpack/lib/action_dispatch/middleware/cookies.rb
  2. +11 −0 actionpack/test/controller/cookie_test.rb
View
1 actionpack/lib/action_dispatch/middleware/cookies.rb
@@ -84,6 +84,7 @@ def []=(key, options)
options[:path] ||= "/"
@set_cookies[key] = options
+ @delete_cookies.delete(key)
value
end
View
11 actionpack/test/controller/cookie_test.rb
@@ -64,6 +64,12 @@ def set_permanent_signed_cookie
cookies.permanent.signed[:remember_me] = 100
head :ok
end
+
+ def delete_and_set_cookie
+ cookies.delete :user_name
+ cookies[:user_name] = { :value => "david", :expires => Time.utc(2005, 10, 10,5) }
+ head :ok
+ end
end
tests TestController
@@ -152,6 +158,11 @@ def test_permanent_signed_cookie
assert_equal 100, @controller.send(:cookies).signed[:remember_me]
end
+ def test_delete_and_set_cookie
+ get :delete_and_set_cookie
+ assert_cookie_header "user_name=david; path=/; expires=Mon, 10-Oct-2005 05:00:00 GMT"
+ assert_equal({"user_name" => "david"}, @response.cookies)
+ end
private
def assert_cookie_header(expected)

0 comments on commit c8dd6f2

Please sign in to comment.