Commit Graph

90991 Commits

Author SHA1 Message Date
Jeremy Daer 4f0f3448cd Marcel 1.0.4
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
2024-03-01 09:29:24 -08:00
Jean Boussier 1c0982d88a
Merge pull request #51232 from Shopify/refactor-insert-all
Refactor InsertAll not to permanently lease a connection
2024-03-01 17:30:03 +01:00
Hartley McGuire 7d008fee70
Merge pull request #51229 from Earlopain/update-bin-rails-test-help-output
Update output of `bin/rails test -h` in testing guide [ci-skip]
2024-03-01 15:37:14 +00:00
Jean Boussier ec7deca7ee Refactor InsertAll not to permanently lease a connection
Extracted from: https://github.com/rails/rails/pull/50793
2024-03-01 15:33:45 +01:00
Jean Boussier 2bf0d68de6 Fix a typo in ConnectionPoool#connection deprecation (again) 2024-03-01 15:32:58 +01:00
Jean Boussier f657842090 Fix a typo in ConnectionPoool#connection deprecation 2024-03-01 15:28:00 +01:00
Jean Boussier e27a0df338
Merge pull request #51230 from Shopify/deprecate-connection
Deprecate `ConnectionPool#connection`
2024-03-01 14:53:09 +01:00
Jean Boussier 7263da542b Deprecate `ConnectionPool#connection`
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
2024-03-01 14:32:55 +01:00
Earlopain 1aa2b9306c
Update output of `bin/rails test -h` in testing guide 2024-03-01 13:32:16 +01:00
Jean Boussier 75e3407917
Merge pull request #51192 from Shopify/connection-leasing-2
Make `.connection` always return a permanently leased connection
2024-03-01 11:50:17 +01:00
Jean Boussier 38e8609ded Make `.connection` always return a permanently leased connection
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.
2024-03-01 11:37:06 +01:00
Jean Boussier 1f6cef4ca5
Merge pull request #51222 from Shopify/ar-clear-pinned-connection-cache
Clear all threads query cache when a connection is pinned
2024-02-29 09:50:48 +01:00
Jean Boussier 1d0b396f40 Clear all threads query cache when a connection is pinned
Ref: https://github.com/Shopify/maintenance_tasks/pull/983#issuecomment-1969407080
Ref: https://github.com/rails/rails/pull/51151

Now that query caches are owned by the pool, and assigned on connections
during checkout, when running multithreaded code inside transactional
tests (typically system tests), the two threads uses the same connection
but not the same cache.

So it's important that we do clear the caches for all threads when
a connection is pinned.
2024-02-29 09:21:18 +01:00
Jean Boussier 3ecc269814
Merge pull request #51213 from Shopify/generic-fixture-accessor
Expose a generic fixture accessor for fixture names that may conflict with Minitest
2024-02-28 16:09:34 +01:00
Jean Boussier ef947f9932 Expose a generic fixture accessor for fixture names that may conflict with Minitest
```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`.
2024-02-28 16:09:23 +01:00
Eileen M. Uchitelle 8bb5620c87
Merge pull request #51165 from joshuay03/query-constraints-confusing-error-with-single-non-primary-key-column
[Fix #51164] `Model.query_constraints` with single non-primary-key column raises incorrect error
2024-02-28 08:12:52 -05:00
Collin Jilbert f14a6298f8
Add Solid Queue to the list of backends in Active Job guide (#51212)
This PR adds Solid Queue to the list of backends for ActiveJob and links to the README for Solid Queue.

[ci skip]
2024-02-28 09:55:47 -03:00
Joshua Young f42d9cbc32 [Fix #51164] `Model.query_constraints` with single non-primary-key column raises incorrect error 2024-02-28 14:19:10 +10:00
Rafael Mendonça França 649e99bf92
Merge pull request #51206 from fatkodima/fix-indexes-for-nonexisting-table
Fix `indexes` method for non-existing MySQL tables
2024-02-27 16:29:49 -05:00
Steve Polito 59a3dd4729
Set `action_mailer.default_url_options` values in `development` and `test` (#51191)
* 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>
2024-02-27 16:19:23 -05:00
Rafael Mendonça França 2772e8ad18
Merge pull request #51207 from Earlopain/fix-tools-profile
Remove `tools/profile`
2024-02-27 15:59:43 -05:00
Earlopain 626e014d34
Remove `tools/profile` 2024-02-27 20:43:30 +01:00
fatkodima 8510efa841 Fix `indexes` method for non-existing MySQL tables 2024-02-27 13:39:01 +02:00
Jean Boussier af85f74418
Merge pull request #51174 from Shopify/connection-less-quoting
Don't require an active connection for table and column quoting
2024-02-27 11:34:32 +01:00
Jean Boussier 0016280f4f Don't require an active connection for table and column quoting
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.
2024-02-27 11:19:00 +01:00
Rafael Mendonça França 0a9ca0107c
✂️ 2024-02-27 02:16:02 +00:00
Rafael Mendonça França 88afcce1dd
Merge pull request #51198 from willnet/fix-wrong-documentation-for-logger_outputs_to
Fix documentation and sample code for `ActiveSupport::Logger.logger_outputs_to?`
2024-02-26 21:08:52 -05:00
Shinichi Maeshima fc62f03ae3
[ci skip]Fix documentation and sample code for `ActiveSupport::Logger.logger_outputs_to?`
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
2024-02-27 10:56:53 +09:00
Rafael Mendonça França a3f884f7a7
Merge pull request #50128 from thiagopradi/main
Removing not used fixtures from ActionPack test suite
2024-02-26 20:52:10 -05:00
Rafael Mendonça França ada3d775bd
Use `Kernel#Array` to wrap the default value 2024-02-27 01:37:54 +00:00
Rafael Mendonça França d216d1ede7
Do not always mark the default translation as html safe
If the `_html` suffis isn't provided we should not mark the default
translation as html safe and escape it.
2024-02-27 01:36:40 +00:00
Carlos Antonio da Silva c402ec7872 Add punctuation on some newly added API docs [ci skip] 2024-02-26 13:32:39 -03:00
Jean Boussier f0864e34d6
Merge pull request #51193 from Shopify/fix-migrator-current-version
Fix `Migrator.current_version` to instantiate `SchemaMigration` correctly
2024-02-26 12:54:26 +01:00
Jean Boussier 6e74098b8c Fix `Migrator.current_version` to instantiate `SchemaMigration` correctly
This was missed in https://github.com/rails/rails/pull/51162
2024-02-26 12:49:31 +01:00
Vipul A M 2abee307fe
Merge pull request #51184 from ConfusedVorlon/document_after_commit_deduplication
[ci skip] Add warning about deduplication of after_xxx_commit shortcuts
2024-02-25 16:30:11 -05:00
Vipul A M e34a0eec38
Merge pull request #51186 from Earlopain/encourage-html-safe-methods-for-safe-join
Docs: Encourage html safe methods for safe join [ci skip]
2024-02-25 11:58:07 -05:00
Vipul A M 4a95c64685
Merge pull request #51187 from lexcao/fix/typo
Fix typo [ci-skip]
2024-02-25 10:21:44 -05:00
Lex Cao 48036fee0d Fix typo 2024-02-25 23:11:40 +08:00
Thiago Pradi 4a91897831
Merge branch 'rails:main' into main 2024-02-25 11:37:47 -03:00
Earlopain 295e7079aa
Docs: Encourage html safe methods for safe join 2024-02-25 12:27:56 +01:00
Rob Jonson 79fa0e3b2d Add warning about deduplication of after_xxx_commit shortcuts 2024-02-24 19:40:13 +00:00
Edouard CHIN 23af6f37a3
Merge pull request #51180 from cjilbert504/patch-1
Update layouts_and_rendering.md
2024-02-24 15:19:07 +01:00
Collin Jilbert 9c01c39480
Update layouts_and_rendering.md
This PR corrects a reference to the act of renaming a partial when in fact it is a local variable that would be renamed instead.
2024-02-24 07:35:07 -06:00
Yasuo Honda 47300002db
Merge pull request #51178 from fatkodima/fix-flaky-multi_db_migrator-test
Fix flaky `multi_db_migrator_test.rb` test
2024-02-24 13:07:07 +09:00
fatkodima 5db70c979e Fix flaky `multi_db_migrator_test.rb` test 2024-02-24 02:38:31 +02:00
Rafael Mendonça França b6285e98f0
Make sure `assert_initializer` accepts a block 2024-02-23 21:54:54 +00:00
Gannon McGibbon bc7dea8c4c
Merge pull request #51173 from gmcgibbon/fix_uri_parse_redirect
Handle bad URIs when filtering redirects
2024-02-23 15:39:18 -06:00
Rafael Mendonça França 8b7e682d86
Merge pull request #51176 from stevepolitodesign/assert-initializer
Introduce `Rails::Generators::Testing::Assertions#assert_initializer`
2024-02-23 15:36:05 -05:00
Steve Polito fb16702fee Introduce `Rails::Generators::Testing::Assertions#assert_initializer`
Compliments the existing [initializer][] generator action.

```rb
assert_initializer "mail_interceptors.rb"
```

[initializer]: https://api.rubyonrails.org/classes/Rails/Generators/Actions.html#method-i-initializer
2024-02-23 10:54:25 -05:00
Jean Boussier cb47c12aa5
Merge pull request #51175 from Shopify/fixtures-connection-pool
Refactor FixtureSet to deal with connection pools
2024-02-23 11:38:08 +01:00