Browse files

Ensure we correctly and immediately load all ENV entries

.. even when the supplied config made no hint that name was relevant.
  • Loading branch information...
1 parent 2369218 commit 8f23c220081d0197107490df9aa6e262fac5099e @matthewd matthewd committed Apr 8, 2014
Showing with 21 additions and 0 deletions.
  1. +21 −0 activerecord/test/cases/connection_adapters/connection_handler_test.rb
View
21 activerecord/test/cases/connection_adapters/connection_handler_test.rb
@@ -70,6 +70,14 @@ def test_resolver_with_database_uri_and_known_key
assert_equal expected, actual
end
+ def test_resolver_with_custom_database_uri_and_no_matching_config
+ ENV['DATABASE_URL_PRODUCTION'] = "postgres://localhost/foo"
+ config = {}
+ actual = resolve(:production, config)
+ expected = { "adapter"=>"postgresql", "database"=>"foo", "host"=>"localhost" }
+ assert_equal expected, actual
+ end
+
def test_resolver_with_custom_database_uri_and_custom_key
ENV['DATABASE_URL_PRODUCTION'] = "postgres://localhost/foo"
config = { "production" => { "adapter" => "not_postgres", "database" => "not_foo", "host" => "localhost" } }
@@ -118,6 +126,19 @@ def test_environment_does_not_exist_in_config_url_does_exist
assert_equal expect_prod, actual["default_env"]
end
+ def test_environment_key_available_immediately
+ ENV['DATABASE_URL_PRODUCTION'] = "postgres://localhost/foo"
+ config = {}
+ actual = klass.new(config).resolve
+ expected = { "production" =>
+ { "adapter" => "postgresql",
+ "database" => "foo",
+ "host" => "localhost"
+ }
+ }
+ assert_equal expected, actual
+ end
+
def test_string_connection
config = { "default_env" => "postgres://localhost/foo" }
actual = klass.new(config).resolve

0 comments on commit 8f23c22

Please sign in to comment.