From 8f23c220081d0197107490df9aa6e262fac5099e Mon Sep 17 00:00:00 2001 From: Matthew Draper Date: Tue, 8 Apr 2014 15:10:15 +0930 Subject: Ensure we correctly and immediately load all ENV entries .. even when the supplied config made no hint that name was relevant. --- .../connection_adapters/connection_handler_test.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/cases/connection_adapters/connection_handler_test.rb b/activerecord/test/cases/connection_adapters/connection_handler_test.rb index dd03f57f19..d6abc13c0d 100644 --- a/activerecord/test/cases/connection_adapters/connection_handler_test.rb +++ b/activerecord/test/cases/connection_adapters/connection_handler_test.rb @@ -70,6 +70,14 @@ module ActiveRecord assert_equal expected, actual end + def test_resolver_with_custom_database_uri_and_no_matching_config + ENV['DATABASE_URL_PRODUCTION'] = "postgres://localhost/foo" + config = {} + actual = resolve(:production, config) + expected = { "adapter"=>"postgresql", "database"=>"foo", "host"=>"localhost" } + assert_equal expected, actual + end + def test_resolver_with_custom_database_uri_and_custom_key ENV['DATABASE_URL_PRODUCTION'] = "postgres://localhost/foo" config = { "production" => { "adapter" => "not_postgres", "database" => "not_foo", "host" => "localhost" } } @@ -118,6 +126,19 @@ module ActiveRecord assert_equal expect_prod, actual["default_env"] end + def test_environment_key_available_immediately + ENV['DATABASE_URL_PRODUCTION'] = "postgres://localhost/foo" + config = {} + actual = klass.new(config).resolve + expected = { "production" => + { "adapter" => "postgresql", + "database" => "foo", + "host" => "localhost" + } + } + assert_equal expected, actual + end + def test_string_connection config = { "default_env" => "postgres://localhost/foo" } actual = klass.new(config).resolve -- cgit v1.2.3