1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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. * `Rails.application.config_for` merges shared configuration deeply.
```yaml ```yaml

View file

@ -16,6 +16,7 @@ module Rails
def start def start
ENV["RAILS_ENV"] ||= @options[:environment] || environment ENV["RAILS_ENV"] ||= @options[:environment] || environment
config = db_config.configuration_hash
case db_config.adapter case db_config.adapter
when /^(jdbc)?mysql/ when /^(jdbc)?mysql/
@ -92,6 +93,7 @@ module Rails
def config def config
db_config.configuration_hash db_config.configuration_hash
end end
deprecate config: "please use db_config.configuration_hash"
def db_config def db_config
return @db_config if defined?(@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 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
end end
def test_config_with_no_db_config def test_config_with_no_db_config
app_db_config(nil) do app_db_config(nil) do
assert_raise(ActiveRecord::AdapterNotSpecified) { assert_raise(ActiveRecord::AdapterNotSpecified) {
Rails::DBConsole.new.config Rails::DBConsole.new.db_config.configuration_hash
} }
end end
end end
@ -56,7 +56,7 @@ class Rails::DBConsoleTest < ActiveSupport::TestCase
}.sort }.sort
app_db_config(nil) do 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
end end
@ -76,7 +76,7 @@ class Rails::DBConsoleTest < ActiveSupport::TestCase
} }
} }
app_db_config(sample_config) do 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
end end
@ -213,7 +213,7 @@ class Rails::DBConsoleTest < ActiveSupport::TestCase
} }
app_db_config(sample_config) do 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
end end