mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #27586 from maclover7/jm-fix-27584
Update `cookies` helper on all HTTP requests
This commit is contained in:
commit
5eff7a9ca7
2 changed files with 11 additions and 3 deletions
|
@ -389,9 +389,7 @@ module ActionController
|
|||
# Note that the request method is not verified. The different methods are
|
||||
# available to make the tests more expressive.
|
||||
def get(action, **args)
|
||||
res = process(action, method: "GET", **args)
|
||||
cookies.update res.cookies
|
||||
res
|
||||
process(action, method: "GET", **args)
|
||||
end
|
||||
|
||||
# Simulate a POST request with the given parameters and set/volley the response.
|
||||
|
@ -519,6 +517,7 @@ module ActionController
|
|||
unless @request.cookie_jar.committed?
|
||||
@request.cookie_jar.write(@response)
|
||||
cookies.update(@request.cookie_jar.instance_variable_get(:@cookies))
|
||||
cookies.update(@response.cookies)
|
||||
end
|
||||
end
|
||||
@response.prepare!
|
||||
|
|
|
@ -395,6 +395,15 @@ class CookiesTest < ActionController::TestCase
|
|||
assert_equal false, cookies.deleted?("another")
|
||||
end
|
||||
|
||||
# Ensure all HTTP methods have their cookies updated
|
||||
[:get, :post, :patch, :put, :delete, :head].each do |method|
|
||||
define_method("test_deleting_cookie_#{method}") do
|
||||
request.cookies[:user_name] = "Joe"
|
||||
public_send method, :logout
|
||||
assert_nil cookies[:user_name]
|
||||
end
|
||||
end
|
||||
|
||||
def test_deleted_cookie_predicate_with_mismatching_options
|
||||
cookies[:user_name] = "Joe"
|
||||
cookies.delete("user_name", path: "/path")
|
||||
|
|
Loading…
Reference in a new issue