Refactor AR's validations_test.rb

The `:context` switch feature is implemented in
ActiveRecord::Validations#valid? method, so we should rename the test
names, and execute `valid?` in the test.

Change test name in AR's validations_test.rb

This test is testing save method's code
Fix Hash#deep_merge bug and improve documentation — resolves #12738

Previously merging into a hash with a falsy value would not result in
the merge-block being called. The fix is simply to check for presence
of the key in the hash.

The documentation example for `deep_merge` now appropriately
demonstrates what a deep merge does.
Fix Formatting in AR Readme

Don't make free form text appear in code blocks [ci skip]
[ci skip] document type_cast_for_write
[ci skip] document ActionDispatch::HTTP::Headers
Merge pull request #12746 from coreyward/master

Fix Hash#deep_merge bug and improve documentation — resolves #12738
Return a non zero code when db has never been setup on status
Add CHANGELOG entry for #14989

Closes #14989
Use Rails::Paths::Path#existent in database_configuration

Database configuration was trying to load the first path that
config.paths['config/database'] was returning even if the path didn't
exist in the filesystem.

Because Rails::Paths::Path has the possibility to return more than 1
path (as an array), database_configuration should filter down the paths
to the existing one and then load the first one.

This would make it possible to move the database.yml file and add the
new path to paths['config/database'] and still load the configurations.
Merge pull request #15015 from pothibo/database-configuration

Use Rails::Paths::Path#existent in database_configuration
Dup the changed_attributes otherwise we could lose them
Merge pull request #15016 from arthurnn/dup_attr_on_save_state

Dup the changed_attributes otherwise we could lose them
Branch name should match in text and code example.

[ci skip]
Merge pull request #15020 from ivantsepp/contributing_to_rails_guide_fix

Mismatch branch name between text and code example [ci skip]
Fixed HABTM's CollectionAssociation size

HABTM should fall back to using the normal CollectionAssociation's size calculation if the collection is not cached or loaded.

This addresses both #14913 and #14914 for master.
pg guide, inet code example. [ci skip]
test, reset changed state in PG's uuid tests.

This resulted in some unrelated errors on Traivs:

  1) Error:
PostgresqlUUIDTest#test_treat_blank_uuid_as_nil:
ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR:  column "thingy" of relation "uuid_data_type" does not exist
LINE 1: INSERT INTO "uuid_data_type" ("thingy") VALUES ($1) RETURNIN...
                                      ^
: INSERT INTO "uuid_data_type" ("thingy") VALUES ($1) RETURNING "id"

/cc @zuhao
Merge pull request #14992 from fredwu/habtm_relation_size_calculation_fix

Habtm relation size calculation fix. Fixes #14913, Fixes #14914.
test, regression test for unparsable PostgreSQL defaults.

This test was inspired by #14866. That PR would break this
functionality and we should make sure we notice that in the future.
set a constant for the "anonymous" habtm model fixes #15022

I wanted the middle model to be anonymous, but we have to give it a name
for marshal support. :'(