Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 0349278f3da9f7f532330cf295eed35ede3bae66 1 parent d17fb9d
Oliver Legg olly authored josh committed
2  actionpack/lib/action_controller/base/cookies.rb
View
@@ -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
6 actionpack/test/controller/cookie_test.rb
View
@@ -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"]
Please sign in to comment.
Something went wrong with that request. Please try again.