2017-07-16 13:10:15 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-01-17 23:20:36 -05:00
|
|
|
require "test_helper"
|
|
|
|
|
|
|
|
module ChannelPrefixTest
|
|
|
|
def test_channel_prefix
|
2018-12-14 16:46:39 -05:00
|
|
|
server2 = ActionCable::Server::Base.new(config: ActionCable::Server::Configuration.new)
|
2020-06-10 08:51:34 -04:00
|
|
|
server2.config.cable = alt_cable_config.with_indifferent_access
|
2017-01-17 23:20:36 -05:00
|
|
|
server2.config.logger = Logger.new(StringIO.new).tap { |l| l.level = Logger::UNKNOWN }
|
|
|
|
|
|
|
|
adapter_klass = server2.config.pubsub_adapter
|
|
|
|
|
|
|
|
rx_adapter2 = adapter_klass.new(server2)
|
|
|
|
tx_adapter2 = adapter_klass.new(server2)
|
|
|
|
|
|
|
|
subscribe_as_queue("channel") do |queue|
|
|
|
|
subscribe_as_queue("channel", rx_adapter2) do |queue2|
|
|
|
|
@tx_adapter.broadcast("channel", "hello world")
|
|
|
|
tx_adapter2.broadcast("channel", "hello world 2")
|
|
|
|
|
|
|
|
assert_equal "hello world", queue.pop
|
|
|
|
assert_equal "hello world 2", queue2.pop
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def alt_cable_config
|
|
|
|
cable_config.merge(channel_prefix: "foo")
|
|
|
|
end
|
|
|
|
end
|