Merge pull request #27416 from voray/remove-throw-from-action-cable

ActionCable should not raise when a connection is already open
This commit is contained in:
Matthew Draper 2017-01-10 01:28:36 +10:30 committed by GitHub
commit 2b555ee9d7
2 changed files with 6 additions and 3 deletions

@ -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?

@ -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}) ->