Merge pull request #42574 from leastbad/connection_identifier

add connection_identifier to ConnectionStub
This commit is contained in:
Rafael França 2021-09-23 19:19:07 -04:00 committed by GitHub
commit ddaf3b2cb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -62,6 +62,25 @@ module ActionCable
def transmit(cable_message)
transmissions << cable_message.with_indifferent_access
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
# Superclass for Action Cable channel functional tests.

View File

@ -62,6 +62,7 @@ class StubConnectionTest < ActionCable::Channel::TestCase
assert_equal "John", subscription.username
assert subscription.admin
assert_equal "John:true", connection.connection_identifier
end
end