Commit Graph

92162 Commits

Author SHA1 Message Date
Igor Depolli
00f38563a4
[ActiveRecord] Add option filter on in_order_of (#51761)
* Add option  on

* Add CHANGELOG and fix method doc

* Rename option to 'filter' and fix grammar

* Adjust filter attribute

* Fix typo and solve conflict

* Update activerecord/test/cases/relation/field_ordered_values_test.rb

Co-authored-by: Timo Schilling <timo@schilling.io>

---------

Co-authored-by: Timo Schilling <timo@schilling.io>
Co-authored-by: Rafael Mendonça França <rafael@rubyonrails.org>
2024-06-12 15:14:06 -07:00
Igor Depolli
4813a0f036
[ActiveSupport] Add option filter on in_order_of (#52072)
* [ActiveSupport] Add option 'filter' on 'in_order_of'

* Update activesupport/lib/active_support/core_ext/enumerable.rb

Co-authored-by: Willian Gustavo Veiga <willianveiga@users.noreply.github.com>

---------

Co-authored-by: Willian Gustavo Veiga <willianveiga@users.noreply.github.com>
Co-authored-by: Rafael Mendonça França <rafael@rubyonrails.org>
2024-06-12 15:13:50 -07:00
Rafael Mendonça França
68b6a1cc57
Merge pull request #52064 from feliperaul/improve_message_verifier_and_signed_id_docs
[ci skip] Improve ActiveSupport::MessageVerifier and ActiveRecord::SignedId docs
2024-06-12 18:00:28 -04:00
Rafael Mendonça França
445529cc3a
Merge pull request #52054 from justinko/issue-52000
Document TestFixtures#fixture
2024-06-12 16:59:19 -04:00
Felipe
ad20d9e7ec
Improve ActiveSupport::MessageVerifier and ActiveRecord::SignedId docs
The documentation on ActiveSupport::MessageVerifier used the “sensitive data” string as an example; that wording might induce the developer to think we’re dealing with encryption, while the payload is actually only Base64 encoded and is not protected at all.

We also improve the documentation on ActiveRecord::SignedId, which uses MessageVerifier and thereby will also expose the ID as encoded cleartext, making explicit that it’s not encryption, only signing.

Lastly, we refer the developer to MessageEncryptor if the payload needs to be encrypted.
2024-06-12 20:46:27 +00:00
fraul
3ba6bc1720
Update the upgrade guides for Rails 7.1 regarding the breaking change (in development/test environments) of the location of secret_key_base (#52083)
Co-authored-by: Felipe <felipe@temporadalivre.com>
2024-06-12 13:15:02 -07:00
Anatoly Busygin
564b434e82
Fix typo in global_executor_concurrency error message (#52103)
* Fix typo in `global_executor_concurrency` error message

* removed `using` and replace multi_thread_pool with `:multi_thread_pool`

Co-authored-by: Petrik de Heus <petrik@deheus.net>

---------

Co-authored-by: Petrik de Heus <petrik@deheus.net>
Co-authored-by: Rafael Mendonça França <rafael@rubyonrails.org>
2024-06-12 12:53:40 -07:00
Rafael Mendonça França
df32c3837d
Merge pull request #52100 from jdlubrano/fix-activerecord-configs-shadowing
Fix ActiveRecord configs variable shadowing
2024-06-12 15:44:34 -04:00
Rafael Mendonça França
ddb82067ec
Merge pull request #52096 from ioquatix/rack-invalid-cookie-key
Don't try to set invalid cookies.
2024-06-12 15:27:30 -04:00
Rafael Mendonça França
c666dac546
Merge pull request #49240 from deepakmahakale/notes-ui
Add an internal route for bin/rails notes
2024-06-12 15:08:49 -04:00
Rafael Mendonça França
db1bbc4070
Merge pull request #52069 from otorain/fix-redundant-package-in-ci-template
remove redundant database package from ci.yml.tt template
2024-06-12 15:06:33 -04:00
Rafael Mendonça França
ba60af6c41
Merge pull request #52099 from justinko/issue-52089
Do not use SyntaxError#path
2024-06-12 15:03:19 -04:00
Joel Lubrano
e6d924ea17
Add configuration test for ActiveRecord being loaded prior to new framework defaults 2024-06-12 18:59:40 +00:00
Rafael Mendonça França
f805261ede
Merge pull request #52101 from ioquatix/fast-smoke-tests
Add support for fast smoke tests.
2024-06-12 14:34:25 -04:00
Samuel Williams
f7f79480d6
Don't try to set invalid cookies.
In Rack 3.1, using invalid cookie keys was deprecated and in Rack 3.2,
using an invalid cookie key will raise an exception.

Escaping cookie keys is non-standard behaviour and is not understood by
clients, e.g. `document.cookies` will contain escaped keys. It also
doesn't round-trip correctly, as in, setting a header with a given name
won't have the same name in subsequent requests. In addition, the
escaping / unescaping behaviour in previous versions of Rack
[caused a security issue](https://github.com/advisories/GHSA-j6w9-fv6q-3q52).
2024-06-12 18:28:41 +00:00
Rafael Mendonça França
8229339593
Merge pull request #52095 from ioquatix/rack-version-constant
Print `Rack.release` as part of default Rails welcome page.
2024-06-12 14:24:24 -04:00
Rafael Mendonça França
ae4386a8e7
Merge pull request #52106 from fresh-eggs/main
Fix action-text-attachment HTML escaping regression test
2024-06-12 14:23:08 -04:00
Rafael Mendonça França
d6316963ef
Merge pull request #52093 from p8/actiontext/fix-remote-image-preview
Only sanitize `content` attribute when present in attachments
2024-06-12 14:21:38 -04:00
Rafael Mendonça França
860f23c0b7
Merge pull request #52108 from fresh-eggs/7-2-stable
[`7-2-stable` Backport] Fix action-text-attachment HTML escaping regression test
2024-06-12 18:20:48 +00:00
Zack Deveau
6678de6ce2 Fix action-text-attachment HTML escaping regression test
Regression test included in 1ac6d40 was not exercising
the correct method. Switched from to_html()
to to_trix_html().
2024-06-12 13:08:26 -04:00
Petrik
52c21f9066 Only sanitize content attribute when present in attachments
When the `content` attribute is set for Action Text attachments, Trix
shows this content.

1ac6d40d36a07b48a67bc7f8627fd1f92bffcb14 introduced sanitizing the
`content` attribute of ActionText::Attachable::ContentAttachment.
However, it would also set the `content` attribute when it isn't
present. Instead of showing the image preview, Trix would use the
empty `content` attribute resulting in missing previews for images.
2024-06-12 13:21:55 +02:00
Samuel Williams
59f1e17831
Add support for fast smoke tests. 2024-06-12 16:51:26 +09:00
Joel Lubrano
247f71bf5b Avoid shadowing block local variable 'configs'
Fix #52098
2024-06-11 23:31:36 -04:00
Justin Ko
07325dc26f Do not use SyntaxError#path
Fixes #52089
2024-06-11 20:26:18 -06:00
Samuel Williams
423959b5b5
Print Rack.release as part of default Rails welcome page. 2024-06-12 10:36:25 +09:00
Rafael Mendonça França
2ebb508cd8
Merge pull request #52086 from y-yagi/bring_back_pumarb_to_app_update
Bring back `puma.rb` to target of `app:update`
2024-06-11 19:37:18 -04:00
Rafael Mendonça França
c60dbbd33e
Merge pull request #52062 from skipkayhil/hm-restore-config-skb
Restore some config.secret_key_base functionality
2024-06-11 19:12:54 -04:00
Matthew Draper
d47c37183a Don't emit to_time deprecations in known-safe contexts
If the value is already a local time, there's no difference, so no need
to warn.

Correspondingly, avoid calling to_time in the handful of places we were
using it internally: it's easy to do, and we know we don't care about
the zone.
2024-06-11 15:51:46 -07:00
Petrik de Heus
8000217130
Merge pull request #52090 from sampatbadhe/patch-16
Correct typo for Active Record Callbacks doc [ci skip]
2024-06-11 18:53:28 +02:00
Sampat Badhe
53194a442e
Correct typo for Active Record Callbacks doc [ci skip] 2024-06-11 21:46:15 +05:30
Yuji Yaginuma
e4f8604602 Bring back puma.rb to target of app:update
This is a partial revert of #41083.

`puma.rb` may update by users, but  Rails has improved `puma.rb` sometimes.
For example, 06d614ada9e4609ff83659e842f48af3232a03a5 and f719787c582839fd2fcd886d70b43da3ddad2ceb.

To allow users to know those improvements, I think we should update
`puma.rb` by `app:update`.
2024-06-11 16:06:30 +09:00
Hartley McGuire
c2901eb084
Restore some config.secret_key_base functionality
The [deprecated secrets removal][1] ended up removing a bit of
non-deprecated functionality related to config.secret_key_base:

- the original implementation prioritized the value of
  config.secret_key_base over other sources in all environments
- if unset, the value of config.secret_key_base would be updated to
  whichever fallback value was found

The new implementation only sets config.secret_key_base to a fallback
value when Rails.env.local?, and never considers it at all in
production.

This commit aims to restore this missing functionality as well as
simplify the implementation:

- Rails.application.secret_key_base now always delegates to
  config.secret_key_base (like the pre-secret-removal implementation)
- secret_key_base validation was moved from the reader to the writer
- config.secret_key_base now handles setting itself to a fallback value
  when unset
- In addition, generate_local_secret was simplified because it
  previously did 3 things: file manipulation, setting
  config.secret_key_base, and returning a value. Now it only creates the
  file if necessary and returns the value stored in it

The new implementation has an additional benefit, which is that manually
set config.secret_key_base values are now validated, whereas previously
only fallback values were validated.

[1]: 0c76f17f2dbf0d7ad90c890e6f334743cacce41f

Co-authored-by: Petrik <petrik@deheus.net>
2024-06-10 23:04:23 -04:00
ian
5871d21d5d remove the redundant database package from ci.yml.tt template 2024-06-10 23:52:28 +08:00
Xavier Noria
51f81267f8
Merge pull request #52080 from rails/fxn/start_transaction_event
Define the new start_transaction.active_record event
2024-06-10 17:45:39 +02:00
Xavier Noria
f64a4134df Define the new start_transaction.active_record event 2024-06-10 17:30:37 +02:00
Petrik de Heus
0733ab5118
Merge pull request #52076 from ibramsterdam/update-active-record-callback-documentation
docs: update list of methods that trigger active record callbacks [ci skip]
2024-06-10 11:54:01 +02:00
Bram Janssen
546b6aadbe docs: update list of methods that trigger active record callbacks 2024-06-10 11:19:29 +02:00
Ridhwana
78d655907a
[RF-DOCS] Active Record Callbacks (#51654)
Review and improve Action View Overview guide. [ci-skip]

* Samples that use Proc.new {} can likely be simplified to just use proc {}
* Link to the validations guide where we mention it under conditional callbacks
* after_find callbacks are also triggered by a few other methods: take, sole, find_by!
* We could potentially add some more examples on different types of callbacks that aren't there.
* Updated some sections for clarity

Co-authored-by: Petrik de Heus <petrik@deheus.net>
Co-authored-by: Carlos Antonio da Silva <carlosantoniodasilva@gmail.com>
Co-authored-by: hatsu <hajiwata0308@gmail.com>
2024-06-10 09:18:24 +02:00
Justin Ko
285d4c812c Document TestFixtures#fixture
Fixes #52000

Co-Authored-By: Hartley McGuire <skipkayhil@gmail.com>
2024-06-09 10:24:27 -06:00
Jean Boussier
e3ea4c7412
Merge pull request #52036 from richardboehme/assert-difference-output
Improve error message when passing a proc to `assert_difference` or `assert_changes`
2024-06-09 10:53:48 +02:00
Richard Böhme
38e9695c10 Improve error message when passing a proc to assert_difference
Previously if `assert_difference` called with a proc fails, the inspect
output of the proc object was shown. This is not helpful to identify
what went wrong.

With this commit we leverage the experimental
`RubyVM::AbstractSyntaxTree` api of MRI to print the source code of the
proc that was passed to `assert_difference`. On all other platforms the
behavior stays the same.

The same applies to `assert_changes`.
2024-06-09 10:46:27 +02:00
Yasuo Honda
fdbe3634df
Merge pull request #52068 from y-yagi/fix_value_for_enqueue_after_transaction_commit
Fix a value for disabling `enqueue_after_transaction_commit` [ci-skip]
2024-06-09 17:10:52 +09:00
yuuji.yaginuma
8c0bbdca09 Fix a value for disabling enqueue_after_transaction_commit [ci-skip]
`enqueue_after_transaction_commit` expects Symbol values, not Boolean.
a472403d55/activejob/lib/active_job/enqueue_after_transaction_commit.rb (L23-L30)
2024-06-09 16:37:21 +09:00
John Hawthorn
a472403d55
Merge pull request #52034 from jhawthorn/ruby_time_zone_object_support
Improve support for using ActiveSupport::TimeZone as a ::Time object's timezone
2024-06-08 15:40:46 -07:00
Jean Boussier
9fdaea5215
Merge pull request #52037 from palkan/feat/active-record/nested-pinning
[ActiveRecord] Support nested connection pinning
2024-06-08 20:59:29 +02:00
fatkodima
08bee538e0 Explicitly load Active Record associations related errors 2024-06-08 14:37:43 +03:00
zzak
33a748a7cf
Rails::ConsoleMethods deprecation warning should point to the source
Before:

```
 (called from Rails::ConsoleMethods.include at /home/zzak/code/rails/railties/lib/rails/console/methods.rb:6)
```

After:

```
 (called from block in <class:Engine> at /home/zzak/.rbenv/versions/3.4.0/lib/ruby/gems/3.4.0+0/bundler/gems/mission_control-jobs-7295d75ed735/lib/mission_control/jobs/engine.rb:73)
```

Co-authored-by: Wojciech Wnętrzak <w.wnetrzak@gmail.com>
2024-06-08 19:54:56 +09:00
Petrik de Heus
8d416d09fc
Merge pull request #52044 from p8/activerecord/tiny-description-fix
Improve documentation of RecordNotSaved and RecordNotDestroyed [ci-skip]
2024-06-08 10:17:34 +02:00
Petrik
18dddcaa64 Improve documentation of RecordNotSaved and RecordNotDestroyed [ci-skip]
Add examples and explain that RecordNotDestroyed triggered by throwing
:abort in callbacks.

Co-authored-by: Carlos Antonio da Silva <carlosantoniodasilva@gmail.com>
2024-06-08 10:11:32 +02:00
Eileen M. Uchitelle
03187f6b1f
Merge pull request #51916 from fatkodima/migrations-primary-without-db-tasks
Fix running migrations on other databases when `database_tasks: false` on primary
2024-06-08 00:58:43 -07:00