Permalink
Browse files

Test DATABASE_URL has precendance over DATABASE_URL_#{environment}

  • Loading branch information...
1 parent e533826 commit d459f751c934529e6a3cff36554a02d6ce7666f4 @rafaelfranca rafaelfranca committed with matthewd Apr 7, 2014
Showing with 9 additions and 0 deletions.
  1. +9 −0 activerecord/test/cases/connection_adapters/connection_handler_test.rb
@@ -45,6 +45,15 @@ def test_resolver_with_environment_database_uri_and_current_env_symbol_key
assert_equal expected, actual
end
+ def test_resolver_with_environment_database_uri_and_global_database_uri_and_current_env_symbol_key
+ ENV['DATABASE_URL'] = "postgres://localhost/foo"
+ ENV['DATABASE_URL_DEFAULT_ENV'] = "mysql://host/foo_bar"
+ config = { "default_env" => { "adapter" => "not_postgres", "database" => "not_foo" } }
+ actual = resolve(:default_env, config)
+ expected = { "adapter"=>"postgresql", "database"=>"foo", "host"=>"localhost" }
+ assert_equal expected, actual
+ end
+
def test_resolver_with_database_uri_and_and_current_env_string_key
ENV['DATABASE_URL'] = "postgres://localhost/foo"
config = { "default_env" => { "adapter" => "not_postgres", "database" => "not_foo" } }

0 comments on commit d459f75

Please sign in to comment.