diff options
author | Matthew Draper <matthew@trebex.net> | 2017-01-10 01:28:36 +1030 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-10 01:28:36 +1030 |
commit | 2b555ee9d7b3b246cc1660de799e3fb83b8fb84f (patch) | |
tree | 821e5c8336a6929ed1c568d8ad2aca5fbad07de4 | |
parent | 7f19f30819dd5a5a788ad9d8b12b5dda76559a12 (diff) | |
parent | 23e3e2bc2bfcc393b9164975e97d5ddc58f8bf5c (diff) | |
download | rails-2b555ee9d7b3b246cc1660de799e3fb83b8fb84f.tar.gz rails-2b555ee9d7b3b246cc1660de799e3fb83b8fb84f.tar.bz2 rails-2b555ee9d7b3b246cc1660de799e3fb83b8fb84f.zip |
Merge pull request #27416 from voray/remove-throw-from-action-cable
ActionCable should not raise when a connection is already open
-rw-r--r-- | actioncable/app/assets/javascripts/action_cable/connection.coffee | 2 | ||||
-rw-r--r-- | actioncable/test/javascript/src/unit/consumer_test.coffee | 7 |
2 files changed, 6 insertions, 3 deletions
diff --git a/actioncable/app/assets/javascripts/action_cable/connection.coffee b/actioncable/app/assets/javascripts/action_cable/connection.coffee index 29ad676290..7fd68cad2f 100644 --- a/actioncable/app/assets/javascripts/action_cable/connection.coffee +++ b/actioncable/app/assets/javascripts/action_cable/connection.coffee @@ -23,7 +23,7 @@ class ActionCable.Connection open: => if @isActive() ActionCable.log("Attempted to open WebSocket, but existing socket is #{@getState()}") - throw new Error("Existing connection must be closed before opening") + false else ActionCable.log("Opening WebSocket, current state is #{@getState()}, subprotocols: #{protocols}") @uninstallEventHandlers() if @webSocket? diff --git a/actioncable/test/javascript/src/unit/consumer_test.coffee b/actioncable/test/javascript/src/unit/consumer_test.coffee index cf8a592255..41445274eb 100644 --- a/actioncable/test/javascript/src/unit/consumer_test.coffee +++ b/actioncable/test/javascript/src/unit/consumer_test.coffee @@ -2,8 +2,11 @@ {consumerTest} = ActionCable.TestHelpers module "ActionCable.Consumer", -> - consumerTest "#connect", connect: false, ({consumer, server, done}) -> - server.on("connection", done) + consumerTest "#connect", connect: false, ({consumer, server, assert, done}) -> + server.on "connection", -> + assert.equal consumer.connect(), false + done() + consumer.connect() consumerTest "#disconnect", ({consumer, client, done}) -> |