aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable
diff options
context:
space:
mode:
authorJay Hayes <ur@iamvery.com>2016-02-24 12:38:48 -0600
committerJay Hayes <ur@iamvery.com>2016-02-24 17:22:06 -0600
commit3ecab078008ca5ce1582cd88d88840504ebed571 (patch)
tree11a650664085d010275f61ce73568e4952a59ab4 /actioncable
parent046e32656efa989a112e9870d8aa25a49f944204 (diff)
downloadrails-3ecab078008ca5ce1582cd88d88840504ebed571.tar.gz
rails-3ecab078008ca5ce1582cd88d88840504ebed571.tar.bz2
rails-3ecab078008ca5ce1582cd88d88840504ebed571.zip
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.
Diffstat (limited to 'actioncable')
-rw-r--r--actioncable/lib/action_cable/server/broadcasting.rb2
-rw-r--r--actioncable/test/server/broadcasting_test.rb15
2 files changed, 16 insertions, 1 deletions
diff --git a/actioncable/lib/action_cable/server/broadcasting.rb b/actioncable/lib/action_cable/server/broadcasting.rb
index f90fe7b9e2..98025f27f2 100644
--- a/actioncable/lib/action_cable/server/broadcasting.rb
+++ b/actioncable/lib/action_cable/server/broadcasting.rb
@@ -26,7 +26,7 @@ module ActionCable
# Returns a broadcaster for a named <tt>broadcasting</tt> that can be reused. Useful when you have an object that
# may need multiple spots to transmit to a specific broadcasting over and over.
def broadcaster_for(broadcasting)
- Broadcaster.new(self, broadcasting)
+ Broadcaster.new(self, String(broadcasting))
end
private
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