mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Memoize cookies so that updates to cookies are available in the current request. [#2733 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
This commit is contained in:
parent
d17fb9dc76
commit
0349278f3d
2 changed files with 7 additions and 1 deletions
|
@ -51,7 +51,7 @@ module ActionController #:nodoc:
|
|||
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 @@ class CookieTest < ActionController::TestCase
|
|||
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"]
|
||||
|
|
Loading…
Reference in a new issue