aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2014-04-08 15:10:15 +0930
committerMatthew Draper <matthew@trebex.net>2014-04-08 15:15:08 +0930
commit8f23c220081d0197107490df9aa6e262fac5099e (patch)
tree801ba05e97829f33d13bc2947151f677540d15b1
parent23692184bbcc2e411ed6bc6d1eaea09aa0f0474f (diff)
downloadrails-8f23c220081d0197107490df9aa6e262fac5099e.tar.gz
rails-8f23c220081d0197107490df9aa6e262fac5099e.tar.bz2
rails-8f23c220081d0197107490df9aa6e262fac5099e.zip
Ensure we correctly and immediately load all ENV entries
.. even when the supplied config made no hint that name was relevant.
-rw-r--r--activerecord/test/cases/connection_adapters/connection_handler_test.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/activerecord/test/cases/connection_adapters/connection_handler_test.rb b/activerecord/test/cases/connection_adapters/connection_handler_test.rb
index dd03f57f19..d6abc13c0d 100644
--- a/activerecord/test/cases/connection_adapters/connection_handler_test.rb
+++ b/activerecord/test/cases/connection_adapters/connection_handler_test.rb
@@ -70,6 +70,14 @@ module ActiveRecord
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 @@ module ActiveRecord
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