Permalink
Browse files

Memoize cookies so that updates to cookies are available in the curre…

…nt request. [#2733 state:resolved]

Signed-off-by: Joshua Peek <josh@joshpeek.com>
  • Loading branch information...
1 parent d17fb9d commit 0349278f3da9f7f532330cf295eed35ede3bae66 @olly olly committed with josh May 28, 2009
Showing with 7 additions and 1 deletion.
  1. +1 −1 actionpack/lib/action_controller/base/cookies.rb
  2. +6 −0 actionpack/test/controller/cookie_test.rb
@@ -51,7 +51,7 @@ def self.included(base)
protected
# Returns the cookie container, which operates as described above.
def cookies
- CookieJar.new(self)
+ @cookies ||= CookieJar.new(self)
end
end
@@ -123,6 +123,12 @@ def test_delete_cookie_with_path
assert_cookie_header "user_name=; path=/beaten; expires=Thu, 01-Jan-1970 00:00:00 GMT"
end
+ def test_cookies_persist_throughout_request
+ get :authenticate
+ cookies = @controller.send(:cookies)
+ assert_equal 'david', cookies['user_name']
+ end
+
private
def assert_cookie_header(expected)
header = @response.headers["Set-Cookie"]

0 comments on commit 0349278

Please sign in to comment.