Commit Graph

91927 Commits

Author SHA1 Message Date
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
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
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, 06d614ada9 and f719787c58.

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]: 0c76f17f2d

Co-authored-by: Petrik <petrik@deheus.net>
2024-06-10 23:04:23 -04: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
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
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
Vladimir Dementyev e44cdcb7a7 feat: support nested connection pinning 2024-06-08 09:16:03 +02:00
John Hawthorn a376cc2e49 Mark TimeZone TZInfo quacking methods as :nodoc: 2024-06-07 20:24:12 -07:00
John Athayde 7dbe81710e
Improve RTL Rendering for Guides (#51613)
Improve RTL language support, specifically focused on Arabic (MSA), Farsi, and Hebrew languages, including custom fonts for those languages, a javascript to detect auto-translation and shift the dir attribute, and other cleanup based on volunteer feedback.

Co-authored-by: Carlos Antonio da Silva <carlosantoniodasilva@gmail.com>
2024-06-07 14:00:52 -03:00
Jean Boussier bc727a04b7
Merge pull request #52042 from Shopify/fix-sprockets-rails-3.5
Unpin sprockets-rails
2024-06-07 11:51:49 +02:00
Jean Boussier a56f5e5aae Update sprockets-rails to 3.5.1
Ref: https://github.com/rails/sprockets-rails/issues/524
2024-06-07 11:29:32 +02:00
Jean Boussier a24edef641
Merge pull request #52041 from yuler/patch-1
Fix typo in active_record_basics.md [skip ci]
2024-06-07 09:45:41 +02:00
Yu Le 25b26cfcb6
Fix typo in active_record_basics.md [skip ci] 2024-06-07 13:27:13 +08:00
Yasuo Honda 63db7d53c3
Merge pull request #52039 from yahonda/pin_sprockets_rails_to_342
Pin `sprockets-rails` version to 3.4.2 or lower
2024-06-07 10:02:29 +09:00
Yasuo Honda a76e272794 Pin `sprockets-rails` version to 3.4.2 or lower
This commit pins `sprockets-rails` version to 3.4.2
until https://github.com/rails/sprockets-rails/issues/524 is fixed.

Refer to https://github.com/rails/rails/issues/52038
2024-06-07 09:37:50 +09:00
Gannon McGibbon 743128b230
Merge pull request #52033 from Shopify/amend_lazy_routes_changelog
Changelog tweak for lazy routes
2024-06-06 14:07:45 -05:00
fatkodima c5ac244c0d Fix running migrations on other databases when `database_tasks: false` on primary 2024-06-06 21:00:54 +03:00
John Hawthorn edc7018742 Add ActiveSupport::TimeZone#dst?
Like abbr, this is used by Ruby when specifying creating a ::Time with a
zone object.
2024-06-06 10:51:18 -07:00
John Hawthorn 262713413c Add ActiveSupport::TimeZone#abbr
As of Ruby 2.6, ::Time supports rich timezone objects and expects them
to follow a similar API to tzinfo. Mostly we already do this with
ActiveSupport::TimeZone, delegating to the underlying tzinfo object,
except we were missing the API to display the timezone's name.

Calling strftime with "%Z" will try the following on the timezone:
* zone.abbr(time)
* zone.strftime("%Z", time)
* zone.name

Because we only implemented name, a ::Time created with an
ActiveSupport::TimeZone would "abbreviate" awkwardly to the full tz
identifier (like "12:34:00 America/Vancouver" instead of "12:34:00
PDT"). This commit implements abbr to make these Times format the same
way as TimeWithZone.

Co-authored-by: Jason Kim <jasonkim@github.com>
2024-06-06 10:43:34 -07:00
Earlopain d56adb8d56 Changelog tweak for lazy routes
Adds context to the changelog that eager-loaded envs will draw routes
eagerly like they did previously.
2024-06-06 11:37:31 -05:00
Gannon McGibbon 6622075802
Merge pull request #52012 from Shopify/defer_route_drawing
Defer route drawing to the first request, or when url_helpers called.
2024-06-06 11:23:47 -05:00
Eileen M. Uchitelle 5dabff4b7b
Merge pull request #51167 from Jay0921/fix-preload-ids-reader-composite-pk
[Fix #51129] Fix issue with IDs reader on preloaded associations for composite primary keys
2024-06-05 07:55:08 -07:00
Carlos Antonio da Silva d36c752287 Add ensure to reset table name in tests 2024-06-05 11:03:18 -03:00
Carlos Antonio da Silva fd5542ee1c Remove changelog, change backported to 7-2-stable
[ci skip]
2024-06-05 11:03:18 -03:00
Carlos Antonio da Silva 6802fac3cd
Merge pull request #52024 from Earlopain/explicit-logger-dep
Add an explicit dependency on the `logger` gem
2024-06-05 10:51:59 -03:00
Earlopain d9adf17fbe
Add an explicit dependency on the `logger` gem
This is getting the same treatment as `base64`, `mutex_m`, etc.
In Ruby 3.4 it will start to warn: d7e558e3c4

Remoce require from two files that don't seem to need it
2024-06-05 13:53:33 +02:00
Vipul A M c628f77112
Merge pull request #52023 from majidalaeinia/main
Resolve Typo
2024-06-05 16:54:25 +05:30
Majid Alaeinia 5737cf9ce0
Update association_basics.md 2024-06-05 04:55:01 +03:30
Yasuo Honda a6a840f150
Merge pull request #51969 from npezza93/insert-all-fix
Parameterize table_name when constructing insert alias to avoid syntax error when table_name contains the database name for mysql
2024-06-05 08:32:23 +09:00
Rafael Mendonça França 8159498aea
Merge pull request #52020 from rails/rm-remove-networks
Remove the default network from the devcontainer compose
2024-06-04 15:55:51 -04:00
Rafael Mendonça França 5cfc1f8f56
Remove the default network from the devcontainer compose
And stop exposing the capybara server port to all interfaces.

We were using this just to make sure the selenium container can access
the capybara server but it can with the default bridge network.
2024-06-04 19:18:07 +00:00
Zack Deveau e215bf3360
Sanitize ActionText HTML ContentAttachment in Trix edit view
[CVE-2024-32464]
Instances of ActionText::Attachable::ContentAttachment included
within a rich_text_area tag could potentially contain unsanitized
HTML. This could lead to a potential cross site scripting issue
within the Trix editor.

This change enforces existing sanitization routines on
ActionText::Attachable::ContentAttachment attachments.
2024-06-04 10:08:12 -07:00
Zack Deveau 35858f1d9d
include the HTTP Permissions-Policy on non-HTML Content-Types
[CVE-2024-28103]

The application configurable Permissions-Policy is only
served on responses with an HTML related Content-Type.

This change allows all Content-Types to serve the
configured Permissions-Policy as there are many non-HTML
Content-Types that would benefit from this header.
(examples include image/svg+xml and application/xml)
2024-06-04 10:07:37 -07:00
Gannon McGibbon 7ac333858c Defer route drawing to the first request, or when url_helpers called.
Executes the first routes reload in middleware, or when the route set
url_helpers is called. Previously, this was executed unconditionally on
boot, which can slow down boot time unnecessarily for larger apps with
lots of routes.
2024-06-04 11:12:12 -05:00
Aaron Patterson f008c31717
Merge pull request #52015 from maniSHarma7575/51991-pluck-columns-should-correctly-casts-types-when-using-postgresql
[FIX] Pluck columns should correctly casts types when using postgresql
2024-06-04 08:55:29 -07:00