Skip to content

Commit d573fb1

Browse files
committed
add connection_identifier to ConnectionStub
1 parent 61d7b79 commit d573fb1

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

actioncable/lib/action_cable/channel/test_case.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,25 @@ def initialize(identifiers = {})
6262
def transmit(cable_message)
6363
transmissions << cable_message.with_indifferent_access
6464
end
65+
66+
def connection_identifier
67+
unless defined? @connection_identifier
68+
@connection_identifier = connection_gid identifiers.filter_map { |id| instance_variable_get("@#{id}") }
69+
end
70+
71+
@connection_identifier
72+
end
73+
74+
private
75+
def connection_gid(ids)
76+
ids.map do |o|
77+
if o.respond_to? :to_gid_param
78+
o.to_gid_param
79+
else
80+
o.to_s
81+
end
82+
end.sort.join(":")
83+
end
6584
end
6685

6786
# Superclass for Action Cable channel functional tests.

0 commit comments

Comments
 (0)