From b42624725054f1c579d6a738701dfdbb2003f087 Mon Sep 17 00:00:00 2001 From: Jay Hayes Date: Wed, 24 Feb 2016 12:33:10 -0600 Subject: whitespace --- actioncable/test/channel/stream_test.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'actioncable/test') diff --git a/actioncable/test/channel/stream_test.rb b/actioncable/test/channel/stream_test.rb index 947efd96d4..ecbee52a4f 100644 --- a/actioncable/test/channel/stream_test.rb +++ b/actioncable/test/channel/stream_test.rb @@ -14,7 +14,6 @@ class ActionCable::Channel::StreamTest < ActionCable::TestCase def send_confirmation transmit_subscription_confirmation end - end test "streaming start and stop" do -- cgit v1.2.3 From 046e32656efa989a112e9870d8aa25a49f944204 Mon Sep 17 00:00:00 2001 From: Jay Hayes Date: Wed, 24 Feb 2016 12:35:36 -0600 Subject: Convert stream broadcasting to a string ActionCable does some things behind the scenes that expects these "broadcasting"s or "channel"s to be strings. However it's not immediately obvious that the value must be a string. So adding this conversion ensures things work as expected. --- actioncable/test/channel/stream_test.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'actioncable/test') diff --git a/actioncable/test/channel/stream_test.rb b/actioncable/test/channel/stream_test.rb index ecbee52a4f..526ea92e4f 100644 --- a/actioncable/test/channel/stream_test.rb +++ b/actioncable/test/channel/stream_test.rb @@ -16,6 +16,12 @@ class ActionCable::Channel::StreamTest < ActionCable::TestCase end end + class SymbolChannel < ActionCable::Channel::Base + def subscribed + stream_from :channel + end + end + test "streaming start and stop" do run_in_eventmachine do connection = TestConnection.new @@ -27,6 +33,17 @@ class ActionCable::Channel::StreamTest < ActionCable::TestCase end end + test "stream from non-string channel" do + run_in_eventmachine do + connection = TestConnection.new + connection.expects(:pubsub).returns mock().tap { |m| m.expects(:subscribe).with("channel", kind_of(Proc), kind_of(Proc)).returns stub_everything(:pubsub) } + channel = SymbolChannel.new connection, "" + + connection.expects(:pubsub).returns mock().tap { |m| m.expects(:unsubscribe) } + channel.unsubscribe_from_channel + end + end + test "stream_for" do run_in_eventmachine do connection = TestConnection.new -- cgit v1.2.3 From 3ecab078008ca5ce1582cd88d88840504ebed571 Mon Sep 17 00:00:00 2001 From: Jay Hayes Date: Wed, 24 Feb 2016 12:38:48 -0600 Subject: Ensure server broadcasts are to string queue names Similar to the channel streaming side, these values must be strings for ActionCable to behave as expected. The conversion will allow users to send string-convertible values and get the expected behavior. --- actioncable/test/server/broadcasting_test.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 actioncable/test/server/broadcasting_test.rb (limited to 'actioncable/test') diff --git a/actioncable/test/server/broadcasting_test.rb b/actioncable/test/server/broadcasting_test.rb new file mode 100644 index 0000000000..3b4a7eaf90 --- /dev/null +++ b/actioncable/test/server/broadcasting_test.rb @@ -0,0 +1,15 @@ +require "test_helper" + +class BroadcastingTest < ActiveSupport::TestCase + class TestServer + include ActionCable::Server::Broadcasting + end + + test "fetching a broadcaster converts the broadcasting queue to a string" do + broadcasting = :test_queue + server = TestServer.new + broadcaster = server.broadcaster_for(broadcasting) + + assert_equal "test_queue", broadcaster.broadcasting + end +end -- cgit v1.2.3