From 88cd65b174d9a75d9cb0e5e06a57615ccc80fff1 Mon Sep 17 00:00:00 2001 From: Matthew Draper Date: Wed, 9 Apr 2014 00:55:49 +0930 Subject: [PATCH] Don't deprecate after all --- .../lib/active_record/connection_handling.rb | 18 ++--------------- .../connection_handler_test.rb | 20 +++++++++---------- 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/activerecord/lib/active_record/connection_handling.rb b/activerecord/lib/active_record/connection_handling.rb index 3667a42864273..31e7390bf77a6 100644 --- a/activerecord/lib/active_record/connection_handling.rb +++ b/activerecord/lib/active_record/connection_handling.rb @@ -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 diff --git a/activerecord/test/cases/connection_adapters/connection_handler_test.rb b/activerecord/test/cases/connection_adapters/connection_handler_test.rb index a7002bd13dd87..256ddd7d235bf 100644 --- a/activerecord/test/cases/connection_adapters/connection_handler_test.rb +++ b/activerecord/test/cases/connection_adapters/connection_handler_test.rb @@ -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 @@ -44,7 +44,7 @@ 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 @@ -52,10 +52,8 @@ def test_resolver_with_database_uri_and_known_key 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 @@ -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 @@ -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 @@ -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" } @@ -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", @@ -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",