mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Dont stream back cookie value if it was set to the same value
This commit is contained in:
parent
ff2667d21a
commit
2d18dd3471
2 changed files with 18 additions and 4 deletions
|
@ -169,12 +169,14 @@ module ActionDispatch
|
|||
options = { :value => value }
|
||||
end
|
||||
|
||||
@cookies[key.to_s] = value
|
||||
|
||||
handle_options(options)
|
||||
|
||||
@set_cookies[key.to_s] = options
|
||||
@delete_cookies.delete(key.to_s)
|
||||
if @cookies[key.to_s] != value or options[:expires]
|
||||
@cookies[key.to_s] = value
|
||||
@set_cookies[key.to_s] = options
|
||||
@delete_cookies.delete(key.to_s)
|
||||
end
|
||||
|
||||
value
|
||||
end
|
||||
|
||||
|
|
|
@ -181,6 +181,18 @@ class CookiesTest < ActionController::TestCase
|
|||
assert_equal({"user_name" => "david"}, @response.cookies)
|
||||
end
|
||||
|
||||
def test_setting_the_same_value_to_cookie
|
||||
request.cookies[:user_name] = 'david'
|
||||
get :authenticate
|
||||
assert response.cookies.empty?
|
||||
end
|
||||
|
||||
def test_setting_the_same_value_to_permanent_cookie
|
||||
request.cookies[:user_name] = 'Jamie'
|
||||
get :set_permanent_cookie
|
||||
assert response.cookies, 'user_name' => 'Jamie'
|
||||
end
|
||||
|
||||
def test_setting_with_escapable_characters
|
||||
get :set_with_with_escapable_characters
|
||||
assert_cookie_header "that+%26+guy=foo+%26+bar+%3D%3E+baz; path=/"
|
||||
|
|
Loading…
Reference in a new issue