Skip to content

Commit

Permalink
Don't deprecate after all
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewd committed Apr 8, 2014
1 parent 615e0dc commit 88cd65b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 27 deletions.
18 changes: 2 additions & 16 deletions activerecord/lib/active_record/connection_handling.rb
Expand Up @@ -73,22 +73,8 @@ def resolve
def config
@raw_config.dup.tap do |cfg|
if url = ENV['DATABASE_URL']
if cfg[@env]
if cfg[@env]["url"]
# Nothing to do
else
ActiveSupport::Deprecation.warn "Overriding database configuration with DATABASE_URL without using an ERB tag in database.yml is deprecated. Please update the entry for #{@env.inspect}:\n\n" \
" #{@env}:\n url: <%= ENV['DATABASE_URL'] %>\n\n"\
"This will be required in Rails 4.2"
cfg[@env]["url"] = url
end
else
cfg[@env] = {}
ActiveSupport::Deprecation.warn "Supplying DATABASE_URL without a matching entry in database.yml is deprecated. Please add an entry for #{@env.inspect}:\n\n" \
" #{@env}:\n url: <%= ENV['DATABASE_URL'] %>\n\n"\
"This will be required in Rails 4.2"
cfg[@env]["url"] ||= url
end
cfg[@env] ||= {}
cfg[@env]["url"] ||= url
end
end
end
Expand Down
Expand Up @@ -28,7 +28,7 @@ def spec(spec, config)
def test_resolver_with_database_uri_and_current_env_symbol_key
ENV['DATABASE_URL'] = "postgres://localhost/foo"
config = { "not_production" => { "adapter" => "not_postgres", "database" => "not_foo" } }
actual = assert_deprecated { resolve(:default_env, config) }
actual = resolve(:default_env, config)
expected = { "adapter"=>"postgresql", "database"=>"foo", "host"=>"localhost" }
assert_equal expected, actual
end
Expand All @@ -44,18 +44,16 @@ def test_resolver_with_database_uri_and_and_current_env_string_key
def test_resolver_with_database_uri_and_known_key
ENV['DATABASE_URL'] = "postgres://localhost/foo"
config = { "production" => { "adapter" => "not_postgres", "database" => "not_foo", "host" => "localhost" } }
actual = assert_deprecated { resolve(:production, config) }
actual = resolve(:production, config)
expected = { "adapter"=>"not_postgres", "database"=>"not_foo", "host"=>"localhost" }
assert_equal expected, actual
end

def test_resolver_with_database_uri_and_unknown_symbol_key
ENV['DATABASE_URL'] = "postgres://localhost/foo"
config = { "not_production" => { "adapter" => "not_postgres", "database" => "not_foo" } }
assert_deprecated do
assert_raises AdapterNotSpecified do
resolve(:production, config)
end
assert_raises AdapterNotSpecified do
resolve(:production, config)
end
end

Expand All @@ -72,7 +70,7 @@ def test_resolver_with_database_uri_and_unknown_string_key
def test_resolver_with_database_uri_and_supplied_url
ENV['DATABASE_URL'] = "not-postgres://not-localhost/not_foo"
config = { "production" => { "adapter" => "also_not_postgres", "database" => "also_not_foo" } }
actual = assert_deprecated { resolve("postgres://localhost/foo", config) }
actual = resolve("postgres://localhost/foo", config)
expected = { "adapter"=>"postgresql", "database"=>"foo", "host"=>"localhost" }
assert_equal expected, actual
end
Expand All @@ -86,7 +84,7 @@ def test_jdbc_url
def test_environment_does_not_exist_in_config_url_does_exist
ENV['DATABASE_URL'] = "postgres://localhost/foo"
config = { "not_default_env" => { "adapter" => "not_postgres", "database" => "not_foo" } }
actual = assert_deprecated { klass.new(config).resolve }
actual = klass.new(config).resolve
expect_prod = { "adapter"=>"postgresql", "database"=>"foo", "host"=>"localhost" }
assert_equal expect_prod, actual["default_env"]
end
Expand Down Expand Up @@ -131,7 +129,7 @@ def test_blank_with_database_url
ENV['DATABASE_URL'] = "postgres://localhost/foo"

config = {}
actual = assert_deprecated { klass.new(config).resolve }
actual = klass.new(config).resolve
expected = { "adapter" => "postgresql",
"database" => "foo",
"host" => "localhost" }
Expand Down Expand Up @@ -162,7 +160,7 @@ def test_merge_no_conflicts_with_database_url
ENV['DATABASE_URL'] = "postgres://localhost/foo"

config = {"default_env" => { "pool" => "5" } }
actual = assert_deprecated { klass.new(config).resolve }
actual = klass.new(config).resolve
expected = { "default_env" =>
{ "adapter" => "postgresql",
"database" => "foo",
Expand All @@ -177,7 +175,7 @@ def test_merge_conflicts_with_database_url
ENV['DATABASE_URL'] = "postgres://localhost/foo"

config = {"default_env" => { "adapter" => "NOT-POSTGRES", "database" => "NOT-FOO", "pool" => "5" } }
actual = assert_deprecated { klass.new(config).resolve }
actual = klass.new(config).resolve
expected = { "default_env" =>
{ "adapter" => "postgresql",
"database" => "foo",
Expand Down

0 comments on commit 88cd65b

Please sign in to comment.