Commit Graph

90983 Commits

Author SHA1 Message Date
Jean Boussier
bbf0b1f33b Refactor some Active Record tests
Mostly extracted from: https://github.com/rails/rails/pull/50793

- Use `#adapter_name` instead of `#class::ADAPTER_NAME`
- Avoid monkey patching some connection instances
- Ignore SCHEMA queries in some asssertions
2024-02-14 12:57:29 +01:00
Jean Boussier
13c1dfe4e0
Merge pull request #50938 from Shopify/refactor-query-cache-to-pool
Refactor QueryCache to be owned by the pool
2024-02-14 11:24:08 +01:00
Jean Boussier
94fc536007 Prune dead thread from connection pool caches on reap
Otherwise they could linger around and leak memory if a user
checkout connections from short lived fibers or threads.

The undocumented `connection_cache_key` hook point is eliminated
because it was essentially add to allow the connection pool to
be fiber based rather than thread based, which is now supported
out of the box.
2024-02-14 10:57:16 +01:00
Jean Boussier
85742ce529 Refactor QueryCache to be owned by the pool
Ref: https://github.com/rails/rails/pull/50793

If we want to stop caching the checked out connections,
then we must persist the cache in the pool, and assign it
to the connection when it's checked out.

The pool become responsible for managing the cache lifecycle.

This also open the door to sharing the cache between multiple
connections, which is valuable for read replicas, etc.

This change only really make sense if we go through with no
longer caching checked out connections. Otherwise it's just
extra complexity.
2024-02-14 10:57:16 +01:00
Jean Boussier
cef567eb87
Merge pull request #51079 from Shopify/duplicable-tests
Update Method#duplicable? to be consistent with Ruby 3.4
2024-02-14 10:33:57 +01:00
Jean Boussier
ca6995a80c Update Method#duplicable? to be consistent with Ruby 3.4
Fix: https://github.com/rails/rails/issues/51075

`Method` and `UnboundMethod` used to raise on `#dup`, but not `#clone`,
this wasn't so much a feature, but a bug.

It was fixed in https://github.com/ruby/ruby/pull/9926.
2024-02-14 09:52:55 +01:00
Yasuo Honda
9b343c2879
Merge pull request #51076 from yahonda/enum_action_mailbox
Address `Defining enums with keyword arguments` warning in Action Mai…
2024-02-14 13:53:37 +09:00
Yasuo Honda
676fe1b8eb Address Defining enums with keyword arguments warning in Action Mailbox
This commit addresses `DEPRECATION WARNING: Defining enums with keyword arguments is deprecated and will be removed`
warning in Action Mailbox.

* Steps to reproduce
```ruby
git clone https://github.com/rails/rails
cd rails/actionmailbox
bundle install
bin/test test/unit/router_test.rb
```

* Without this commit
```
$ bin/test test/unit/router_test.rb
... snip ..
DEPRECATION WARNING: Defining enums with keyword arguments is deprecated and will be removed
in Rails 7.3. Positional arguments should be used instead:

enum :status, [:pending, :processing, :delivered, :failed, :bounced]
 (called from <class:InboundEmail> at /home/yahonda/src/github.com/rails/rails/actionmailbox/app/models/action_mailbox/inbound_email.rb:31)
Run options: --seed 65254

...............

Finished in 0.230357s, 65.1163 runs/s, 108.5271 assertions/s.
15 runs, 25 assertions, 0 failures, 0 errors, 0 skips
$
```

Follow up https://github.com/rails/rails/pull/50987
Refer to https://github.com/rails/rails/pull/51037
2024-02-14 12:13:46 +09:00
Yasuo Honda
aafbf0a4a7
Merge pull request #51040 from hendrixfan/remove-rollup-option
remove unknown rollup input option breakOnWarning
2024-02-14 11:40:05 +09:00
Jason Nochlin
fc9ed119c7
Deprecate config.active_record.warn_on_records_fetched_greater_than (#51007)
* Deprecate config.active_record.warn_on_records_fetched_greater_than

* Review changes

Co-authored-by: Rafael Mendonça França <rafael@franca.dev>

---------

Co-authored-by: Jason Nochlin <hundredwatt@users.noreply.github.com>
Co-authored-by: Rafael Mendonça França <rafael@franca.dev>
2024-02-13 18:20:55 -05:00
Rafael Mendonça França
f8ffd46ccc
Merge pull request #51063 from anonychun/speedup-docker-build-time
Speedup Docker Build Time
2024-02-13 18:17:05 -05:00
Rafael Mendonça França
2e4a2b7eea
Merge pull request #51068 from Edouard-chin/ec-dont-load-test-from-fixture
Don't load `*_test.rb` file from the "fixtures" folder:
2024-02-13 18:09:24 -05:00
Rafael Mendonça França
a9573eaa6b
Merge pull request #51035 from rails/rm-docs-actioncable
Transform actioncable documentation to Markdown
2024-02-13 17:55:42 -05:00
John Hawthorn
c730877c49
Merge pull request #51019 from jhawthorn/key-provider
Remove memoization to accept `key_provider` overridden by `with_encryption_context`
2024-02-13 13:10:38 -08:00
Mike Kasberg
72410ffc49 Fix typo in Debugging Guide [ciskip]
While I was reading the Debugging Rails Applications guide, this typo
threw me off and I had to re-read it to understand the intended meaning,
so it seems like it's worth fixing.

And after digging in a little more, rewording the `path` example can add
some clarity.
2024-02-13 13:35:07 -07:00
Rafael Mendonça França
154f7c2181
Register autoload for ActiveJob::Arguments
Since #50715, there are cases where `ActiveJob::Arguments` is used
but not required anymore in the test environment. This could be a
test for a custom argument serializer.

One solution could be to add a require "active_job/arguments" in
all the usages, but that isn't a convention we follow in Rails.

Instead, let's register the autoload for `ActiveJob::Arguments` in
`active_job.rb` so that it's always available when needed.
2024-02-13 20:34:10 +00:00
Eileen M. Uchitelle
8e20f5d3b2
Merge pull request #51072 from eileencodes/raise-error-for-trilogy-and-prepared-statements
Raise error for Trilogy when `prepared_statements` is `true`
2024-02-13 15:08:58 -05:00
eileencodes
847953dbaa
Raise error for Trilogy when prepared_statements is true
Trilogy doesn't currently support prepared statements. The error that
applications would see is a `StatementInvalid` error. This doesn't quite point
you to the fact this isn't supported. So raise a more appropriate error
pointing to what to change.
2024-02-13 14:47:43 -05:00
Edouard CHIN
ce9f13c97e Don't load *_test.rb file from the "fixtures" folder:
- If an application has files named `*_test.rb` in the
  "fixtures/files" folder, they were picked up to be loaded.
  In most cases this would result in a LoadError as its likely
  those files include code that can't be loaded.
2024-02-13 19:01:14 +01:00
Achmad Chun Chun
bdb8a6dcf7 change from deploy to base 2024-02-13 22:19:12 +07:00
Achmad Chun Chun
78061ebfe8 speedup docker build time 2024-02-13 20:26:14 +07:00
Yasuo Honda
6e7ef7d61c
Merge pull request #51037 from fatkodima/fix-deprecated-enum-syntax-tests
Fix deprecated `enum` syntax in tests
2024-02-13 21:37:23 +09:00
Yasuo Honda
ec684bbe51
Merge pull request #51060 from yahonda/workaround_thumbnail_height
Address `ActiveStorage::VariantTest#test_resized_variation_of_WEBP_blob` failure at Rails Nightly CI
2024-02-13 21:29:45 +09:00
Yasuo Honda
034398fdfe Address ActiveStorage::VariantTest#test_resized_variation_of_WEBP_blob failure at Rails Nightly CI
Managed to reproduce Rails Nightly CI failure
at https://buildkite.com/rails/rails-nightly/builds/149#018d9052-1b2d-48fa-9d74-a39df3f3f1d6/1251-1291

This commit allows both 33 and 34 as its height because this issue is isolated
that thedifference comes from libvips and/or ruby-vips behavior differences, not Active Storage.

* Steps to reprodude
Run this test on Ubuntu 22.04. It should not reproduce on Ubuntu 23.10.

```
git clone https://github.com/rails/rails
cd rails
rm Gemfile.lock
cd activestorage
bin/test test/models/variant_test.rb -n test_resized_variation_of_WEBP_blob
```

* Expected behavior
It should pass.

* Actual behavior
It fails because the height of the thumbnail is 34.

```
$ bin/test test/models/variant_test.rb -n test_resized_variation_of_WEBP_blob
F

Failure:
ActiveStorage::VariantTest#test_resized_variation_of_WEBP_blob [test/models/variant_test.rb:125]:
Expected: 33
  Actual: 34

bin/test test/models/variant_test.rb:117
```

Refer to https://github.com/libvips/ruby-vips/issues/383
2024-02-13 21:04:08 +09:00
Petrik de Heus
a42ca9cf14
Merge pull request #51049 from sobstel/main
[DOCS] Warn against uniqueness validator when create_or_find_by is used [ci-skip]
2024-02-13 07:45:59 +01:00
Przemek Sobstel
a42eda12da doc: Warn against having uniqueness validator when create_or_find_by is used
Co-authored-by: Petrik de Heus <petrik@deheus.net>
2024-02-13 07:23:58 +01:00
zzak
d850686939
Add preview_docs rake task for generating API and Guides static site 2024-02-13 13:05:49 +09:00
Yasuo Honda
e4f1c8758c
Merge pull request #50962 from joshuay03/update-has-one-create-test-descriptions
Update some create `has_one` failure test descriptions
2024-02-13 10:07:04 +09:00
Eileen M. Uchitelle
631429056b
Merge pull request #50606 from maximerety/active-record-encryption-eager-load
[Fix #50604] Restore compatibility of Active Record Encryption configs with eager loading mode
2024-02-12 16:13:23 -05:00
maximerety
d997c554b3
[Fix #50604] Restore compatibility of ARE configs with eager loading mode
Configure ActiveRecord::Encryption (ARE) on ActiveRecord::Base (AR)
loading, so that ARE configs are ready before AR models start using
`encrypts` to declare encrypted attributes.

This means that you can add ARE configurations in initializers, as long
as you don't trigger the loading of ActiveRecord::Base or your AR models
in prior initializers.
2024-02-12 17:57:56 +01:00
Jean Boussier
f5910f74d4
Merge pull request #51050 from Shopify/show-exception-report-error
ActionDispatch::Executor: report errors handled by ShowExceptions
2024-02-12 17:51:02 +01:00
Jean Boussier
4067c9565a ActionDispatch::Executor: report errors handled by ShowExceptions
Fix: https://github.com/rails/rails/issues/51002

In the default middleware stack, the `ShowExceptions` middleware is
lower than `ActionDispatch::Execturor` and will handle most exceptions
causing `Executor` not to witness any.

Instead we need to rely on `action_dispatch.exception` being added
into the request env.
2024-02-12 17:40:24 +01:00
Nikita Vasilevsky
19a1680c17
Fix update_all/delete_all on CPK model relation with join subquery 2024-02-12 16:35:59 +00:00
Jean Boussier
9940dc879d docker-entrypoint: export LD_PRELOAD
Otherwise it won't applied to the execed process.

Fix: https://github.com/rails/rails/pull/50943#issuecomment-1936443319
2024-02-12 14:15:16 +01:00
Jean Boussier
a8d6d477c7
Merge pull request #50999 from Shopify/refactor-transactional-fixtures
Decouple transactional fixtures and active connections
2024-02-12 09:54:39 +01:00
Javier Aranda
a60039b8dc
Document that lock_version column is integer 2024-02-11 18:19:21 +01:00
Joshua Young
e61234dac7 Update create has_one failure test descriptions 2024-02-11 19:42:23 +10:00
lsglucas
ca73646b4a fix: outdated cors initializer docs 2024-02-10 13:30:00 -03:00
Wolfgang Fournès
33e5ce5fce remove unknown rollup input option breakOnWarning
As seen in https://buildkite.com/rails/rails/builds/104749#018d92dc-79b9-42bc-9a8c-bbcf5681f9eb/1165-1176 breakOnWarning does not seem to be a valid option for Rollup. I cannot find in the documentation, and therefore I think it can safely be removed.
2024-02-10 14:05:39 +01:00
Xavier Noria
0f9aaa5ca9
Merge pull request #51039 from rails/update-release-notes
Update 7.0 release notes re inflections and the once autoloader
2024-02-10 12:51:56 +01:00
Xavier Noria
5876939a5a Update 7.0 release notes re inflections and the once autoloader 2024-02-10 12:42:40 +01:00
fatkodima
93884c66d5 Fix deprecated enum syntax in tests 2024-02-10 12:42:54 +02:00
Rafael Mendonça França
1a92af2b51
Merge pull request #50987 from skipkayhil/hm-deprecate-kw-enum
Deprecate defining enums with keywords args
2024-02-09 20:32:13 -05:00
Hartley McGuire
8c5425197c
Deprecate defining enums with keywords args
Enums have historically been defined using keyword arguments:

```ruby
class Function > ApplicationRecord
  enum color: [:red, :blue],
       type: [:instance, :class],
       _scopes: false
```

This has the advantage of being able to define multiple enums at once
with the same options. However, it also has a downside that enum options
must be prefixed with an underscore to separate them from the enum
definitions (to enable models to have enums with the same name as an
option).

In Rails 7, a new syntax was [introduced][1] to instead define enums with
positional arguments:

```ruby
class Function > ApplicationRecord
  enum :color, [:red, :blue], scopes: false
  enum :type, [:instance, :class], scopes: false
```

This new syntax eliminates the need to prefix options with an underscore,
and the docs were updated to recommend this new syntax.

However, both versions of the API have been supported since, and it has
started to cause some problems:

The first issue is that the available options have drifted. In Rails
7.1, an option was added to make assigning an invalid enum value use
validation errors instead of runtime errors. However, the equivalent
underscored prefix option was not added for the original enum syntax

Articles have been created that describe the new option in Rails 7.1,
but the examples in the articles use un-prefixed options with the old
syntax. This confusion has also lead to issues opened asking why that
incorrect syntax is not working.

Additionally, the presence of underscored options is just generally
confusing because it tends to imply an option is for internal use.

This commit aims to fix all of these issues by deprecating the old enum
syntax. With only one way to define enums, options cannot drift and
there will be less confusion around how enums should be defined.

[1]: 0618d2d84a501aea93c898aec504ff9a0e09d6f2
2024-02-10 00:20:45 +00:00
Rafael Mendonça França
6fdd31d7db
Transform actioncable documentation to Markdown 2024-02-10 00:11:26 +00:00
Rafael Mendonça França
f0adde935e
Fix configuration order 2024-02-09 23:50:00 +00:00
Rafael Mendonça França
fdc5ec228e
Merge PR #50953 2024-02-09 23:46:44 +00:00
Lewis Buckley
a15f5b837f
Add note about imagemagick / libvips support being required 2024-02-09 23:45:18 +00:00
Lewis Buckley
f3e3f82e7d
Add WebP as a new framework default image type
Follows https://github.com/rails/rails/pull/38918 and
https://github.com/rails/rails/pull/38988

At the time, webp browser support was limited. Now 96% of browsers
support webp: https://caniuse.com/?search=webp
2024-02-09 23:44:51 +00:00
Rafael Mendonça França
cd053bcedc
Merge pull request #50992 from KJTsanaktsidis/ktsanaktsidis/persist_logger_tags_until_as_event
Don't pop logger tags in Rails::Rack::Logger until request is finished
2024-02-09 18:38:55 -05:00