1
0
Fork 0
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:
Rafael Mendonça França 2021-11-19 23:04:04 +00:00
parent 73605a253e
commit 190f006e78
No known key found for this signature in database
GPG key ID: FC23B6D0F1EEE948
4 changed files with 6 additions and 24 deletions

View file

@ -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*

View file

@ -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?

View file

@ -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)

View file

@ -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`.