aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2016-02-05 22:56:52 +0100
committerKasper Timm Hansen <kaspth@gmail.com>2016-02-14 17:46:48 +0100
commit861ece99bb6d7ebdb27fad7db5ccc05340aaf0e5 (patch)
treeedfbd5ef05e31e58d986c9e000d122454e9934e5 /actioncable
parent661298176c72eefc6d0f42b58210119e76962364 (diff)
downloadrails-861ece99bb6d7ebdb27fad7db5ccc05340aaf0e5.tar.gz
rails-861ece99bb6d7ebdb27fad7db5ccc05340aaf0e5.tar.bz2
rails-861ece99bb6d7ebdb27fad7db5ccc05340aaf0e5.zip
Default connection class to ActionCable::Connection::Base.
Instead of depending on ApplicationCable::Connection being defined at initialize we should inject it in the Railtie. Thus we can kill more setup in the tests too.
Diffstat (limited to 'actioncable')
-rw-r--r--actioncable/lib/action_cable/engine.rb4
-rw-r--r--actioncable/lib/action_cable/server/configuration.rb4
-rw-r--r--actioncable/test/client_test.rb8
-rw-r--r--actioncable/test/subscription_adapter/common.rb8
4 files changed, 6 insertions, 18 deletions
diff --git a/actioncable/lib/action_cable/engine.rb b/actioncable/lib/action_cable/engine.rb
index acca3961d8..f5f1cb59e0 100644
--- a/actioncable/lib/action_cable/engine.rb
+++ b/actioncable/lib/action_cable/engine.rb
@@ -31,6 +31,10 @@ module ActionCable
self.cable = Rails.application.config_for(config_path).with_indifferent_access
end
+ if 'ApplicationCable::Connection'.safe_constantize
+ self.connection_class = ApplicationCable::Connection
+ end
+
self.channel_paths = Rails.application.paths['app/channels'].existent
options.each { |k,v| send("#{k}=", v) }
diff --git a/actioncable/lib/action_cable/server/configuration.rb b/actioncable/lib/action_cable/server/configuration.rb
index 019a374734..58bb8ff65a 100644
--- a/actioncable/lib/action_cable/server/configuration.rb
+++ b/actioncable/lib/action_cable/server/configuration.rb
@@ -13,8 +13,8 @@ module ActionCable
def initialize
@log_tags = []
- @connection_class = ApplicationCable::Connection
- @worker_pool_size = 100
+ @connection_class = ActionCable::Connection::Base
+ @worker_pool_size = 100
@disable_request_forgery_protection = false
end
diff --git a/actioncable/test/client_test.rb b/actioncable/test/client_test.rb
index f2b090cc52..d294fa7bc6 100644
--- a/actioncable/test/client_test.rb
+++ b/actioncable/test/client_test.rb
@@ -13,9 +13,6 @@ class ClientTest < ActionCable::TestCase
def setup
# TODO: ActionCable requires a *lot* of setup at the moment...
- ::Object.const_set(:ApplicationCable, Module.new)
- ::ApplicationCable.const_set(:Connection, Class.new(ActionCable::Connection::Base))
-
ActionCable.instance_variable_set(:@server, nil)
server = ActionCable.server
inner_logger = Logger.new(StringIO.new).tap { |l| l.level = Logger::UNKNOWN }
@@ -36,11 +33,6 @@ class ClientTest < ActionCable::TestCase
def teardown
$VERBOSE = @previous_verbose
-
- begin
- ::Object.send(:remove_const, :ApplicationCable)
- rescue NameError
- end
end
def with_puma_server(rack_app = ActionCable.server, port = 3099)
diff --git a/actioncable/test/subscription_adapter/common.rb b/actioncable/test/subscription_adapter/common.rb
index 1b6f8c70bf..b06e3cb761 100644
--- a/actioncable/test/subscription_adapter/common.rb
+++ b/actioncable/test/subscription_adapter/common.rb
@@ -10,9 +10,6 @@ module CommonSubscriptionAdapterTest
def setup
# TODO: ActionCable requires a *lot* of setup at the moment...
- ::Object.const_set(:ApplicationCable, Module.new)
- ::ApplicationCable.const_set(:Connection, Class.new(ActionCable::Connection::Base))
-
server = ActionCable::Server::Base.new
inner_logger = Logger.new(StringIO.new).tap { |l| l.level = Logger::UNKNOWN }
server.config.logger = ActionCable::Connection::TaggedLoggerProxy.new(inner_logger, tags: [])
@@ -30,11 +27,6 @@ module CommonSubscriptionAdapterTest
def teardown
@tx_adapter.shutdown if @tx_adapter && @tx_adapter != @rx_adapter
@rx_adapter.shutdown if @rx_adapter
-
- begin
- ::Object.send(:remove_const, :ApplicationCable)
- rescue NameError
- end
end