1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix database configurations building when DATABASE_URL present

This commit is contained in:
Vladimir Dementyev 2019-02-12 17:00:17 -05:00
parent 7432e25187
commit d9b261a340
No known key found for this signature in database
GPG key ID: 8E0A19D3D1EDF5EB
2 changed files with 11 additions and 1 deletions

View file

@ -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

View file

@ -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" } }