Merge pull request #42574 from leastbad/connection_identifier
add connection_identifier to ConnectionStub
This commit is contained in:
commit
ddaf3b2cb3
|
@ -62,6 +62,25 @@ module ActionCable
|
||||||
def transmit(cable_message)
|
def transmit(cable_message)
|
||||||
transmissions << cable_message.with_indifferent_access
|
transmissions << cable_message.with_indifferent_access
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def connection_identifier
|
||||||
|
unless defined? @connection_identifier
|
||||||
|
@connection_identifier = connection_gid identifiers.filter_map { |id| send(id.to_sym) if id }
|
||||||
|
end
|
||||||
|
|
||||||
|
@connection_identifier
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def connection_gid(ids)
|
||||||
|
ids.map do |o|
|
||||||
|
if o.respond_to? :to_gid_param
|
||||||
|
o.to_gid_param
|
||||||
|
else
|
||||||
|
o.to_s
|
||||||
|
end
|
||||||
|
end.sort.join(":")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Superclass for Action Cable channel functional tests.
|
# Superclass for Action Cable channel functional tests.
|
||||||
|
|
|
@ -62,6 +62,7 @@ class StubConnectionTest < ActionCable::Channel::TestCase
|
||||||
|
|
||||||
assert_equal "John", subscription.username
|
assert_equal "John", subscription.username
|
||||||
assert subscription.admin
|
assert subscription.admin
|
||||||
|
assert_equal "John:true", connection.connection_identifier
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue