Skip to content

Commit 066c413

Browse files
committed
Reapply "Merge pull request rails#27586 from maclover7/jm-fix-27584"
This reverts commit 6902ca5. This was originally reverted due to a reported regression, however the regression appeared to be present without this patch as well (and was fixed in a later [commit][1]. [1]: ca937c5
1 parent dee911b commit 066c413

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

actionpack/lib/action_controller/test_case.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,7 @@ def determine_default_controller_class(name)
429429
# Note that the request method is not verified. The different methods are
430430
# available to make the tests more expressive.
431431
def get(action, **args)
432-
res = process(action, method: "GET", **args)
433-
cookies.update res.cookies
434-
res
432+
process(action, method: "GET", **args)
435433
end
436434

437435
# Simulate a POST request with the given parameters and set/volley the response.
@@ -639,6 +637,7 @@ def process_controller_response(action, cookies, xhr)
639637
unless @request.cookie_jar.committed?
640638
@request.cookie_jar.write(@response)
641639
cookies.update(@request.cookie_jar.instance_variable_get(:@cookies))
640+
cookies.update(@response.cookies)
642641
end
643642
end
644643
@response.prepare!

actionpack/test/dispatch/cookies_test.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,15 @@ def test_deleted_cookie_predicate
583583
assert_equal false, cookies.deleted?("another")
584584
end
585585

586+
# Ensure all HTTP methods have their cookies updated
587+
[:get, :post, :patch, :put, :delete, :head].each do |method|
588+
define_method("test_deleting_cookie_#{method}") do
589+
request.cookies[:user_name] = "Joe"
590+
public_send method, :logout
591+
assert_nil cookies[:user_name]
592+
end
593+
end
594+
586595
def test_deleted_cookie_predicate_with_mismatching_options
587596
cookies[:user_name] = "Joe"
588597
cookies.delete("user_name", path: "/path")

0 commit comments

Comments
 (0)