Update tests to clarify content type detection heuristic after exposing
a regression in Marcel 1.0.3 that wasn't caught by its test suite:
1. magic bytes
2. declared content type, unless it's binary
3. filename extension
4. binary: application/octet-stream
Replaced by `#lease_connection` to better reflect what it does.
`ActiveRecord::Base#connection` is deprecated in the same way
but without a removal timeline nor a deprecation warning.
Inside the Active Record test suite, we do remove `Base.connection`
to ensure it's not used internally.
Some callsites have been converted to use `with_connection`,
some other have been more simply migrated to `lease_connection`
and will serve as a list of callsites to convert for
https://github.com/rails/rails/pull/50793
Ref: https://github.com/rails/rails/pull/51083
The introduction of `ActiveRecord::Base.with_connection` somewhat broke
some expectations, namely that calling `.connection` would cause the
connection to be permenently leased, hence that future calls to it
would return the same connection, with all it's possible environmental
changes.
So any call to `.connection`, even inside `.with_connection` should
cause the lease to be sticky, and persist beyond the `with_connection`
block.
Also rename `.connection` into `.lease_connection`, as to make it
more explicit.
```ruby
assert_equal "Ruby on Rails", web_sites(:rubyonrails).name
assert_equal "Ruby on Rails", fixture(:web_sites, :rubyonrails).name
```
This was brought to me by someone with a `Metadata` model. The fixtures
accessor being `metadata` which conflicts with the `metadata` method
recently added in `Minitest`.
* Set `action_mailer.default_url_options` values in `development` and `test`.
Prior to this commit, new Rails applications would raise
`ActionView::Template::Error` if a mailer included a url built with a
`*_path` helper.
Since we already know [new apps will be served on `localhost:3000`][new
apps], we set this as the value in `development`.
In an effort to remain consistent with existing patters, we set the
`host` to `www.example.com` in `test.
[new apps]: 47300002db/README.md?plain=1#L81
* Update railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt
Co-authored-by: Rafael Mendonça França <rafael@franca.dev>
---------
Co-authored-by: Rafael Mendonça França <rafael@franca.dev>
Extracted from: https://github.com/rails/rails/pull/50793
Right now quoting table or column names requires a leased Adapter
instance, even though none of the implementations actually requires
an active connection.
The idea here is to move these methods to the class so that the quoting
can be done without leasing a connection or even needing the connection
to ever have been established.
I also checked `activerecord-sqlserver-adapter` and `oracle-enhanced`
gems, and neither need an active connection.
Fixed incorrect documentation for `ActiveSupport::Logger.logger_outputs_to?`. The method expects the first argument to be a Logger object and subsequent variadic arguments to be either IO objects or strings representing file paths.
Also corrected the sample code in CHANGELOG.md, which previously only passed a single argument, not reflecting the correct usage.
related PR: https://github.com/rails/rails/pull/51125