diff options
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/connection_adapters/connection_handler_test.rb | 21 |
1 files changed, 21 insertions, 0 deletions
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 |