aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/database_configurations_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Avoid to use a method that acts on the hashyuuji.yaginuma2019-07-271-1/+1
| | | | To avoid a deprecation warning.
* Merge pull request #36372 from instructure-bridge/6-0-stableRafael França2019-07-261-5/+8
| | | Don't break configurations.each, .first before the deprecation period
* Improve errors and handling of hashes for database configurationseileencodes2019-02-141-0/+117
In chat Sam Saffron asked how to use the setter now that configurations is no longer a hash and you need to do AR::Base.configurations["test"]=. Technically you can do `ActiveRecord::Base.configurations = { the hash }` but I realized the old way throws an error and is unintuitive. To aid in the transition from hashes to objects this PR makes a few changes: 1) Re-adds a deprecated hash setter `[]=` that will add a new hash to the configurations list OR replace an existing hash if that environment is already present. This won't be supported in future Rails versions but a good error is important. 2) Changed to throw deprecation warnings on the methods we decided to support for hash conversion and raise on the methods we don't support. 3) Refactored the setter/getter hash deprecation warnings messages and rewrote them. Getters message: ``` DEPRECATION WARNING: `ActiveRecord::Base.configurations` no longer returns a hash. Methods that act on the hash like `values` are deprecated and will be removed in Rails 6.1. Use the `configs_for` method to collect and iterate over the database configurations. ``` Setter message: ``` DEPRECATION WARNING: Setting `ActiveRecord::Base.configurations` with `[]=` is deprecated. Use `ActiveRecord::Base.configurations=` directly to set the configurations instead. ``` 4) Rewrote the legacy configurations test file to test all the public methods in the DatabaseConfigurations class.