Merge pull request #37963 from eileencodes/deprecate-config-in-dbconsole

Deprecate config in dbconsole
This commit is contained in:
Eileen M. Uchitelle 2019-12-16 09:27:24 -05:00 committed by GitHub
commit 3578f6929b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 5 deletions

View File

@ -1,3 +1,9 @@
* Deprecate `Rails::DBConsole#config`
`Rails::DBConsole#config` is deprecated without replacement. Use `Rails::DBConsole.db_config.configuration_hash` instead.
*Eileen M. Uchitelle*, *John Crepezzi*
* `Rails.application.config_for` merges shared configuration deeply.
```yaml

View File

@ -16,6 +16,7 @@ module Rails
def start
ENV["RAILS_ENV"] ||= @options[:environment] || environment
config = db_config.configuration_hash
case db_config.adapter
when /^(jdbc)?mysql/
@ -92,6 +93,7 @@ module Rails
def config
db_config.configuration_hash
end
deprecate config: "please use db_config.configuration_hash"
def db_config
return @db_config if defined?(@db_config)

View File

@ -30,14 +30,14 @@ class Rails::DBConsoleTest < ActiveSupport::TestCase
}
}
app_db_config(config_sample) do
assert_equal config_sample["test"].symbolize_keys, Rails::DBConsole.new.config
assert_equal config_sample["test"].symbolize_keys, Rails::DBConsole.new.db_config.configuration_hash
end
end
def test_config_with_no_db_config
app_db_config(nil) do
assert_raise(ActiveRecord::AdapterNotSpecified) {
Rails::DBConsole.new.config
Rails::DBConsole.new.db_config.configuration_hash
}
end
end
@ -56,7 +56,7 @@ class Rails::DBConsoleTest < ActiveSupport::TestCase
}.sort
app_db_config(nil) do
assert_equal expected, Rails::DBConsole.new.config.sort
assert_equal expected, Rails::DBConsole.new.db_config.configuration_hash.sort
end
end
@ -76,7 +76,7 @@ class Rails::DBConsoleTest < ActiveSupport::TestCase
}
}
app_db_config(sample_config) do
assert_equal host, Rails::DBConsole.new.config[:host]
assert_equal host, Rails::DBConsole.new.db_config.configuration_hash[:host]
end
end
@ -213,7 +213,7 @@ class Rails::DBConsoleTest < ActiveSupport::TestCase
}
app_db_config(sample_config) do
assert_equal "postgresql", Rails::DBConsole.new.config[:adapter]
assert_equal "postgresql", Rails::DBConsole.new.db_config.configuration_hash[:adapter]
end
end