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:
parent
7432e25187
commit
d9b261a340
2 changed files with 11 additions and 1 deletions
|
@ -157,7 +157,7 @@ module ActiveRecord
|
||||||
configs
|
configs
|
||||||
else
|
else
|
||||||
configs.map do |config|
|
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
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
|
@ -72,6 +72,16 @@ module ActiveRecord
|
||||||
assert_equal expected, actual
|
assert_equal expected, actual
|
||||||
end
|
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
|
def test_resolver_with_database_uri_and_unknown_symbol_key
|
||||||
ENV["DATABASE_URL"] = "postgres://localhost/foo"
|
ENV["DATABASE_URL"] = "postgres://localhost/foo"
|
||||||
config = { "not_production" => { "adapter" => "not_postgres", "database" => "not_foo" } }
|
config = { "not_production" => { "adapter" => "not_postgres", "database" => "not_foo" } }
|
||||||
|
|
Loading…
Reference in a new issue