aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorEileen M. Uchitelle <eileencodes@users.noreply.github.com>2019-07-08 05:06:25 -0400
committerGitHub <noreply@github.com>2019-07-08 05:06:25 -0400
commit84ff4f6ea2a118b47160e3fe7ed29bff52c2a7a2 (patch)
tree7170c5c0159b5c0c8d0a0202021cd8d16b3700c5 /activerecord/test
parent7729dfc6ef0bfddcf55c214b86c7e2530024d58a (diff)
parentff42b21915c08cf44f2c263dfe13c249dd780528 (diff)
downloadrails-84ff4f6ea2a118b47160e3fe7ed29bff52c2a7a2.tar.gz
rails-84ff4f6ea2a118b47160e3fe7ed29bff52c2a7a2.tar.bz2
rails-84ff4f6ea2a118b47160e3fe7ed29bff52c2a7a2.zip
Merge pull request #36617 from wjessop/fix_database_url_trampling_other_env_configs
When DATABASE_URL is specified don't trample envs that use a url: key
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb19
1 files changed, 19 insertions, 0 deletions
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 c0a9f8f9ca..6372abbf3f 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
@@ -244,6 +244,25 @@ module ActiveRecord
assert_equal expected, actual
end
+ def test_no_url_sub_key_with_database_url_doesnt_trample_other_envs
+ ENV["DATABASE_URL"] = "postgres://localhost/baz"
+
+ config = { "default_env" => { "database" => "foo" }, "other_env" => { "url" => "postgres://foohost/bardb" } }
+ actual = resolve_config(config)
+ expected = { "default_env" =>
+ { "database" => "baz",
+ "adapter" => "postgresql",
+ "host" => "localhost"
+ },
+ "other_env" =>
+ { "adapter" => "postgresql",
+ "database" => "bardb",
+ "host" => "foohost"
+ }
+ }
+ assert_equal expected, actual
+ end
+
def test_merge_no_conflicts_with_database_url
ENV["DATABASE_URL"] = "postgres://localhost/foo"