Tests for indifferent access using full_messages_for. Closes #11916
Make sure we clean preview_interceptors

We should make sure we clean preview_interceptors after each test so they dont leaky to the next test
Fix OrderedHash.select to return self instance.

On ruby 2.1.1 the behavior of .select and .reject has changed.
They will return a Hash new instance, so we need to override them to
keep the instance object class.
Merge pull request #14327 from zzak/backport_a94966e

Backport a94966e
Merge pull request #14326 from arthurnn/backport_14318

Make sure we clean preview_interceptors
Move setting :scope_level_resource to resource_scope

Originally with_scope_level was exclusively for managing scope levels with
resources, however it is now used for other things so it makes more sense
to move the responsibility for setting the :scope_level_resource to the
resource_scope method. This eliminates repeatedly setting it to the same
resource as each resource method scope is evaluated.

(cherry picked from commit ed0fb4ae7ea28cf3eecce6ec02650bcffc7c7657)
Only use shallow nested scope when depth is > 1

By tracking the depth of resource nesting we can push the need for nested
shallow scoping to only those routes that are nested more than one deep.
This allows us to keep the fix for #12498 and fix the regression in #14224.

Fixes #14224.

(cherry picked from commit dcc91a04a177466516dac12abc358c590743fa71)
Pull namespace defaults out of the options hash

If a developer has specified either :path or :as in the options hash then
these should be used as the defaults for :shallow_path and :shallow_prefix.

Fixes #14241.

(cherry picked from commit 8711086f5a2e73cd068434a5fafef258ba9f4fe1)
Copy shallow options from normal options when using scope

If the options :shallow_prefix and :shallow_path are not set in the
scope options then copy them from the normal :as and :path options
if they are set.

(cherry picked from commit af4c9b78ff1c967cc1aaef14d34205ef92db8134)
Update the CHANGELOG to reflect the changes made at 58db2df

[ci skip]
The 4.1 release notes is already a thing so lets show in the guides
links
Merge pull request #8313 from alan/only_save_changed_has_one_objects

Save has_one associations only if record has changes

Conflicts:
	activerecord/CHANGELOG.md

Conflicts:
	activerecord/CHANGELOG.md
Fixes STI when 2+ levels deep.

PR #14052 Added a regression where it was only looking for methods in one
level up, So when the method was defined in a 2+ levels up the
inheritance chain, the method was not found as defined.
only write the jar if the response isn't committed

when streaming responses, we need to make sure the cookie jar is written
to the headers before returning up the stack. This commit introduces a
new method on the response object that writes the cookie jar to the
headers as the response is committed.  The middleware and test framework
will not write the cookie headers if the response has already been
committed.

fixes #14352
use the body proxy to freeze headers

avoid freezing the headers until the web server has actually read data
from the body proxy.  Once the webserver has read data, then we should
throw an error if someone tries to set a header

Conflicts:
	actionpack/lib/action_controller/metal/live.rb
Use Sqlite3 adapter in examples

Two bits of example code use sqlite as an adapter, which doesn't exist.
Using the code verbatim will raise a LoadError exception:

    ActiveRecord::Base.establish_connection(
      "adapter"  => "sqlite",
      "database" => "db.sqlite"
    )
    # => LoadError: Could not load 'active_record/connection_adapters/sqlite_adapter'...

Considering this is code a lot of people new to Rails might be running,
it's especially confusing.

Closes #14367 [ci skip]
make tests pass on Ruby 2.2

Apparently we've been using a buggy feature for the past 6 years:

  https://bugs.ruby-lang.org/issues/9593
require actions rather than create_file

thor's create_file seems to have a circular dependency on itself when
used with our constant loading stuff.

fixes #14319
Merge pull request #14372 from arthurnn/fix_query_cache_binds

Make select_all on query cache accept a Relation without binds.
Conflicts:
	activerecord/CHANGELOG.md
No need to binds be optional