Allow missing Action Cable config
Since #37850, `config_for` returns `nil` instead of an empty Hash when a config file does not contain configuration for the specified environment. Thus, the return value should be converted to a Hash before calling `with_indifferent_access`. Fixes #40548.
This commit is contained in:
parent
53e97f0fa0
commit
949e4587d5
@ -30,7 +30,7 @@ class Engine < Rails::Engine # :nodoc:
|
||||
|
||||
ActiveSupport.on_load(:action_cable) do
|
||||
if (config_path = Pathname.new(app.config.paths["config/cable"].first)).exist?
|
||||
self.cable = Rails.application.config_for(config_path).with_indifferent_access
|
||||
self.cable = Rails.application.config_for(config_path).to_h.with_indifferent_access
|
||||
end
|
||||
|
||||
previous_connection_class = connection_class
|
||||
|
@ -2453,6 +2453,14 @@ class ::DummySerializer < ActiveJob::Serializers::ObjectSerializer; end
|
||||
assert_nil ActiveStorage.queues[:purge]
|
||||
end
|
||||
|
||||
test "ActionCable.server.config.cable is set when missing configuration for the current environment" do
|
||||
quietly do
|
||||
app "missing"
|
||||
end
|
||||
|
||||
assert_kind_of ActiveSupport::HashWithIndifferentAccess, ActionCable.server.config.cable
|
||||
end
|
||||
|
||||
test "ActionMailbox.logger is Rails.logger by default" do
|
||||
app "development"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user