diff options
Diffstat (limited to 'actioncable/test/subscription_adapter/redis_test.rb')
-rw-r--r-- | actioncable/test/subscription_adapter/redis_test.rb | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/actioncable/test/subscription_adapter/redis_test.rb b/actioncable/test/subscription_adapter/redis_test.rb index 3dc995331a..35840a4036 100644 --- a/actioncable/test/subscription_adapter/redis_test.rb +++ b/actioncable/test/subscription_adapter/redis_test.rb @@ -11,7 +11,11 @@ class RedisAdapterTest < ActionCable::TestCase include ChannelPrefixTest def cable_config - { adapter: "redis", driver: "ruby" } + { adapter: "redis", driver: "ruby" }.tap do |x| + if host = URI(ENV["REDIS_URL"] || "").hostname + x[:host] = host + end + end end end @@ -25,19 +29,27 @@ class RedisAdapterTest::AlternateConfiguration < RedisAdapterTest def cable_config alt_cable_config = super.dup alt_cable_config.delete(:url) - alt_cable_config.merge(host: "127.0.0.1", port: 6379, db: 12) + alt_cable_config.merge(host: URI(ENV["REDIS_URL"] || "").hostname || "127.0.0.1", port: 6379, db: 12) end end class RedisAdapterTest::Connector < ActionCable::TestCase - test "slices url, host, port, db, and password from config" do - config = { url: 1, host: 2, port: 3, db: 4, password: 5 } + test "slices url, host, port, db, password and id from config" do + config = { url: 1, host: 2, port: 3, db: 4, password: 5, id: "Some custom ID" } assert_called_with ::Redis, :new, [ config ] do connect config.merge(other: "unrelated", stuff: "here") end end + test "adds default id if it is not specified" do + config = { url: 1, host: 2, port: 3, db: 4, password: 5, id: "ActionCable-PID-#{$$}" } + + assert_called_with ::Redis, :new, [ config ] do + connect config.except(:id) + end + end + def connect(config) ActionCable::SubscriptionAdapter::Redis.redis_connector.call(config) end |