mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Remove deprecated ActiveRecord::Base.configurations.to_h
This commit is contained in:
parent
73605a253e
commit
190f006e78
4 changed files with 6 additions and 24 deletions
|
@ -1,3 +1,7 @@
|
|||
* Remove deprecated `ActiveRecord::Base.configurations.to_h`.
|
||||
|
||||
*Rafael Mendonça França*
|
||||
|
||||
* Remove deprecated `ActiveRecord::Base.configurations.default_hash`.
|
||||
|
||||
*Rafael Mendonça França*
|
||||
|
|
|
@ -91,14 +91,6 @@ module ActiveRecord
|
|||
first_config && name == first_config.name
|
||||
end
|
||||
|
||||
# Returns the DatabaseConfigurations object as a Hash.
|
||||
def to_h
|
||||
configurations.inject({}) do |memo, db_config|
|
||||
memo.merge(db_config.env_name => db_config.configuration_hash.stringify_keys)
|
||||
end
|
||||
end
|
||||
deprecate to_h: "You can use `ActiveRecord::Base.configurations.configs_for(env_name: 'env', name: 'primary').configuration_hash` to get the configuration hashes."
|
||||
|
||||
# Checks if the application's configurations are empty.
|
||||
#
|
||||
# Aliased to blank?
|
||||
|
|
|
@ -85,25 +85,9 @@ class DatabaseConfigurationsTest < ActiveRecord::TestCase
|
|||
assert_equal ActiveRecord::ConnectionHandling::DEFAULT_ENV.call, config.env_name
|
||||
assert_equal ":memory:", config.database
|
||||
end
|
||||
|
||||
def test_to_h_turns_db_config_object_back_into_a_hash_and_is_deprecated
|
||||
configs = ActiveRecord::Base.configurations
|
||||
assert_equal "ActiveRecord::DatabaseConfigurations", configs.class.name
|
||||
assert_deprecated do
|
||||
assert_equal "Hash", configs.to_h.class.name
|
||||
assert_equal ["arunit", "arunit2", "arunit_without_prepared_statements"], ActiveRecord::Base.configurations.to_h.keys.sort
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class LegacyDatabaseConfigurationsTest < ActiveRecord::TestCase
|
||||
def test_can_turn_configurations_into_a_hash_and_is_deprecated
|
||||
assert_deprecated do
|
||||
assert ActiveRecord::Base.configurations.to_h.is_a?(Hash), "expected to be a hash but was not."
|
||||
assert_equal ["arunit", "arunit2", "arunit_without_prepared_statements"].sort, ActiveRecord::Base.configurations.to_h.keys.sort
|
||||
end
|
||||
end
|
||||
|
||||
def test_unsupported_method_raises
|
||||
assert_raises NoMethodError do
|
||||
ActiveRecord::Base.configurations.fetch(:foo)
|
||||
|
|
|
@ -260,6 +260,8 @@ Please refer to the [Changelog][active-job] for detailed changes.
|
|||
|
||||
* Remove deprecated `ActiveRecord::Base.configurations.default_hash`.
|
||||
|
||||
* Remove deprecated `ActiveRecord::Base.configurations.to_h`.
|
||||
|
||||
### Deprecations
|
||||
|
||||
* Deprecated `Rails.config.active_job.skip_after_callbacks_if_terminated`.
|
||||
|
|
Loading…
Reference in a new issue