aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorJohn Crepezzi <seejohnrun@github.com>2019-07-25 20:08:10 -0400
committerJohn Crepezzi <seejohnrun@github.com>2019-07-25 20:14:21 -0400
commit5e260574a43d5c2fef8b170138baa9f7e10bfb24 (patch)
tree6b3cf3dceafbb1bad11a651ef83e43c3ab06b199 /activerecord/test
parentec7aa03c984a0daeead4f71c7189d241139a6770 (diff)
downloadrails-5e260574a43d5c2fef8b170138baa9f7e10bfb24.tar.gz
rails-5e260574a43d5c2fef8b170138baa9f7e10bfb24.tar.bz2
rails-5e260574a43d5c2fef8b170138baa9f7e10bfb24.zip
Only merge DATABASE_URL settings into the current env
This commit fixes a regression where when the `DATABASE_URL` environment variable was set and the current Rails environment had a valid configuration defined in the database config, settings from the environment variable would affect _all_ environments (not just the current one).
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb16
1 files changed, 16 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 15a045ed23..95e57f42e3 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
@@ -347,6 +347,22 @@ module ActiveRecord
assert_equal expected, actual
end
end
+
+ def test_does_not_change_other_environments
+ ENV["DATABASE_URL"] = "postgres://localhost/foo"
+ config = { "production" => { "adapter" => "not_postgres", "database" => "not_foo", "host" => "localhost" }, "default_env" => {} }
+
+ actual = resolve_spec(:production, config)
+ assert_equal config["production"].merge("name" => "production"), actual
+
+ actual = resolve_spec(:default_env, config)
+ assert_equal({
+ "host" => "localhost",
+ "database" => "foo",
+ "adapter" => "postgresql",
+ "name" => "default_env"
+ }, actual)
+ end
end
end
end