Skip to content

Commit

Permalink
Merge pull request #48321 from moofkit/fix-sentinels-config-with-stri…
Browse files Browse the repository at this point in the history
…ngs-arguments

Fix ActionCable Redis configuration with sentinels
  • Loading branch information
byroot committed May 29, 2023
2 parents c77e460 + f1ace63 commit d381d24
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion actioncable/lib/action_cable/subscription_adapter/redis.rb
Expand Up @@ -58,7 +58,7 @@ def redis_connection
end

def config_options
@config_options ||= @server.config.cable.symbolize_keys.merge(id: identifier)
@config_options ||= @server.config.cable.deep_symbolize_keys.merge(id: identifier)
end

class Listener < SubscriberMap
Expand Down
28 changes: 28 additions & 0 deletions actioncable/test/subscription_adapter/redis_test.rb
Expand Up @@ -122,3 +122,31 @@ def expected_connection
super.except(:adapter, :channel_prefix)
end
end

class RedisAdapterTest::SentinelConfigAsHash < ActionCable::TestCase
def setup
server = ActionCable::Server::Base.new
server.config.cable = cable_config.merge(adapter: "redis").with_indifferent_access
server.config.logger = Logger.new(StringIO.new).tap { |l| l.level = Logger::UNKNOWN }

@adapter = server.config.pubsub_adapter.new(server)
end

def cable_config
{ url: "redis://test", sentinels: [{ "host" => "localhost", "port" => 26379 }] }
end

def expected_connection
{ url: "redis://test", sentinels: [{ host: "localhost", port: 26379 }], id: connection_id }
end

def connection_id
"ActionCable-PID-#{$$}"
end

test "sets sentinels as array of hashes with keyword arguments" do
assert_called_with ::Redis, :new, [ expected_connection ] do
@adapter.send(:redis_connection)
end
end
end

0 comments on commit d381d24

Please sign in to comment.