Skip to content

Commit

Permalink
Default connection class to ActionCable::Connection::Base.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kaspth committed Feb 14, 2016
1 parent 6612981 commit 861ece9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 18 deletions.
4 changes: 4 additions & 0 deletions actioncable/lib/action_cable/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class Railtie < Rails::Engine # :nodoc:
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) }
Expand Down
4 changes: 2 additions & 2 deletions actioncable/lib/action_cable/server/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class Configuration
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
Expand Down
8 changes: 0 additions & 8 deletions actioncable/test/client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -36,11 +33,6 @@ def setup

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)
Expand Down
8 changes: 0 additions & 8 deletions actioncable/test/subscription_adapter/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: [])
Expand All @@ -30,11 +27,6 @@ def setup
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


Expand Down

0 comments on commit 861ece9

Please sign in to comment.