diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2015-10-19 15:14:22 -0500 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2015-10-19 15:14:22 -0500 |
commit | 506d84c157b041208f40b7034cac9c5d5e66fff5 (patch) | |
tree | fba84aec142722d5381906a2ed5d9c01dc5e2152 /test | |
parent | 0d99cfd5ca755643a23beec22513072987c8edba (diff) | |
download | rails-506d84c157b041208f40b7034cac9c5d5e66fff5.tar.gz rails-506d84c157b041208f40b7034cac9c5d5e66fff5.tar.bz2 rails-506d84c157b041208f40b7034cac9c5d5e66fff5.zip |
Make sure the subscription confirmaion is only sent out once
Diffstat (limited to 'test')
-rw-r--r-- | test/channel/stream_test.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/channel/stream_test.rb b/test/channel/stream_test.rb index 08cfef5736..d651ba1746 100644 --- a/test/channel/stream_test.rb +++ b/test/channel/stream_test.rb @@ -10,6 +10,11 @@ class ActionCable::Channel::StreamTest < ActionCable::TestCase stream_from "test_room_#{@room.id}" end end + + def send_confirmation + transmit_subscription_confirmation + end + end test "streaming start and stop" do @@ -53,4 +58,23 @@ class ActionCable::Channel::StreamTest < ActionCable::TestCase end end + test "stream_from subscription confirmation should only be sent out once" do + EM.run do + connection = TestConnection.new + connection.stubs(:pubsub).returns EM::Hiredis.connect.pubsub + + channel = ChatChannel.new connection, "test_channel" + channel.send_confirmation + channel.send_confirmation + + EM.run_deferred_callbacks + + expected = ActiveSupport::JSON.encode "identifier" => "test_channel", "type" => "confirm_subscription" + assert_equal expected, connection.last_transmission, "Did not receive subscription confirmation within 0.1s" + + assert_equal 1, connection.transmissions.size + EM.stop + end + end + end |