File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed
lib/action_cable/connection Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -30,16 +30,23 @@ def assert_reject_connection(&block)
30
30
end
31
31
end
32
32
33
+ class TestCookies < ActiveSupport ::HashWithIndifferentAccess
34
+ def []=( name , options )
35
+ value = options . is_a? ( Hash ) ? options . symbolize_keys [ :value ] : options
36
+ super ( name , value )
37
+ end
38
+ end
39
+
33
40
# We don't want to use the whole "encryption stack" for connection unit-tests,
34
41
# but we want to make sure that users test against the correct types of cookies
35
42
# (i.e. signed or encrypted or plain)
36
- class TestCookieJar < ActiveSupport :: HashWithIndifferentAccess
43
+ class TestCookieJar < TestCookies
37
44
def signed
38
- self [ : signed] ||= { } . with_indifferent_access
45
+ @ signed ||= TestCookies . new
39
46
end
40
47
41
48
def encrypted
42
- self [ : encrypted] ||= { } . with_indifferent_access
49
+ @ encrypted ||= TestCookies . new
43
50
end
44
51
end
45
52
Original file line number Diff line number Diff line change @@ -47,6 +47,14 @@ def test_plain_cookie
47
47
assert_equal "456" , connection . user_id
48
48
end
49
49
50
+ def test_plain_cookie_with_explicit_value_and_string_key
51
+ cookies [ "user_id" ] = { "value" => "456" }
52
+
53
+ connect
54
+
55
+ assert_equal "456" , connection . user_id
56
+ end
57
+
50
58
def test_disconnect
51
59
cookies [ "user_id" ] = "456"
52
60
@@ -133,6 +141,14 @@ def test_connected_with_encrypted_cookies
133
141
assert_equal "456" , connection . user_id
134
142
end
135
143
144
+ def test_connected_with_encrypted_cookies_with_explicit_value_and_symbol_key
145
+ cookies . encrypted [ "user_id" ] = { value : "456" }
146
+
147
+ connect
148
+
149
+ assert_equal "456" , connection . user_id
150
+ end
151
+
136
152
def test_connection_rejected
137
153
assert_reject_connection { connect }
138
154
end
You can’t perform that action at this time.
0 commit comments