2017-07-16 13:10:15 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-10-02 09:02:01 -04:00
|
|
|
require "test_helper"
|
|
|
|
require "stubs/test_server"
|
|
|
|
require "active_support/core_ext/hash/indifferent_access"
|
|
|
|
|
2018-06-08 16:19:39 -04:00
|
|
|
class BaseTest < ActionCable::TestCase
|
2016-10-02 09:02:01 -04:00
|
|
|
def setup
|
|
|
|
@server = ActionCable::Server::Base.new
|
|
|
|
@server.config.cable = { adapter: "async" }.with_indifferent_access
|
|
|
|
end
|
|
|
|
|
|
|
|
class FakeConnection
|
|
|
|
def close
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
test "#restart closes all open connections" do
|
|
|
|
conn = FakeConnection.new
|
|
|
|
@server.add_connection(conn)
|
|
|
|
|
2018-04-22 12:33:40 -04:00
|
|
|
assert_called(conn, :close) do
|
|
|
|
@server.restart
|
|
|
|
end
|
2016-10-02 09:02:01 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
test "#restart shuts down worker pool" do
|
2018-04-22 12:33:40 -04:00
|
|
|
assert_called(@server.worker_pool, :halt) do
|
|
|
|
@server.restart
|
|
|
|
end
|
2016-10-02 09:02:01 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
test "#restart shuts down pub/sub adapter" do
|
2018-04-22 12:33:40 -04:00
|
|
|
assert_called(@server.pubsub, :shutdown) do
|
|
|
|
@server.restart
|
|
|
|
end
|
2016-10-02 09:02:01 -04:00
|
|
|
end
|
|
|
|
end
|