diff options
author | Vladimir Dementyev <dementiev.vm@gmail.com> | 2019-02-12 17:00:17 -0500 |
---|---|---|
committer | Vladimir Dementyev <dementiev.vm@gmail.com> | 2019-02-12 17:00:17 -0500 |
commit | d9b261a340477a291fb404e0cc759821f6d62811 (patch) | |
tree | 5830ce228e9204ad71c442991790e7e4a9aceea6 | |
parent | 7432e251873690234d0d288e8eb009fbee80b635 (diff) | |
download | rails-d9b261a340477a291fb404e0cc759821f6d62811.tar.gz rails-d9b261a340477a291fb404e0cc759821f6d62811.tar.bz2 rails-d9b261a340477a291fb404e0cc759821f6d62811.zip |
Fix database configurations building when DATABASE_URL present
-rw-r--r-- | activerecord/lib/active_record/database_configurations.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/database_configurations.rb b/activerecord/lib/active_record/database_configurations.rb index 73adf66684..654a01f23b 100644 --- a/activerecord/lib/active_record/database_configurations.rb +++ b/activerecord/lib/active_record/database_configurations.rb @@ -157,7 +157,7 @@ module ActiveRecord configs else configs.map do |config| - ActiveRecord::DatabaseConfigurations::UrlConfig.new(env, config.spec_name, url, config.config) + ActiveRecord::DatabaseConfigurations::UrlConfig.new(config.env_name, config.spec_name, url, config.config) end end else diff --git a/activerecord/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb b/activerecord/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb index 225cccc62c..515bf5df06 100644 --- a/activerecord/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb +++ b/activerecord/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb @@ -72,6 +72,16 @@ module ActiveRecord assert_equal expected, actual end + def test_resolver_with_database_uri_and_multiple_envs + ENV["DATABASE_URL"] = "postgres://localhost" + ENV["RAILS_ENV"] = "test" + + config = { "production" => { "adapter" => "postgresql", "database" => "foo_prod" }, "test" => { "adapter" => "postgresql", "database" => "foo_test" } } + actual = resolve_spec(:test, config) + expected = { "adapter" => "postgresql", "database" => "foo_test", "host" => "localhost", "name" => "test" } + assert_equal expected, actual + end + def test_resolver_with_database_uri_and_unknown_symbol_key ENV["DATABASE_URL"] = "postgres://localhost/foo" config = { "not_production" => { "adapter" => "not_postgres", "database" => "not_foo" } } |