Commit Graph

89067 Commits

Author SHA1 Message Date
Rafael Mendonça França acfa045405
Revert typography change in user facing errors
This change would force a lot of existing applications and libraries
to update their tests.

We included it in the beta to collect feedback from the community and
we had some comments about how negative this change would be.

Developers that care about the typography of their error messages
can easily change it in their applications using the translation
files, so there is no need to inflict pain in the upgrade process
by changing the default in the framework.

Revert "Merge PR #45463"

This reverts commit 9f60cd8dc7, reversing
changes made to 35d574dbfd.
2023-09-26 21:45:03 +00:00
Rafael Mendonça França 99cf11cca4
Merge pull request #45369 from seanpdoyle/action-controller-parameters-deep-merge
Support `ActionController::Parameters#deep_merge`
2023-09-26 17:41:17 -04:00
Sean Doyle 1d999e681e Support `ActionController::Parameters#deep_merge`
When [rails/rails#20868][] changed the `ActionController::Parameters`
ancestory from `HashWithIndifferentAccess` to `Object`, support for
`#deep_merge` and `#deep_merge!` were omitted.

This commit restores support by integrating with
[ActiveSupport::DeepMergeable](./activesupport/lib/active_support/deep_mergeable.rb).

[rails/rails#20868]: https://github.com/rails/rails/pull/20868

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2023-09-26 16:27:28 -05:00
Rafael Mendonça França 2e93162e42
Merge pull request #48115 from aki77/add_expired_at
Add `expires_at` option to `ActiveStorage::Blob#signed_id`
2023-09-26 17:21:33 -04:00
Rafael Mendonça França a8e7c2dd99
Merge pull request #49395 from ipc103/remove-dirty-current-transactions-stub
Remove unneeded stub from adapter test
2023-09-26 17:12:51 -04:00
aki 1f9fbbe213
Add `expires_at` option to `ActiveStorage::Blob#signed_id` 2023-09-26 21:08:20 +00:00
Jonathan Hefner 5fcc61076d Use monospace font for code snippets and options [ci-skip] 2023-09-26 15:48:31 -05:00
Ryuta Kamizono 6ef9007cf5
Merge pull request #49393 from kamipo/changelog_for_unique_constraint
Add a CHANGELOG entry for #49383
2023-09-27 02:53:45 +09:00
Ryuta Kamizono 1fe4538635 Fix `rewhere`'s link for API doc in the guide
This was accidentally changed at #47010.
2023-09-27 02:43:22 +09:00
Eileen M. Uchitelle 68cd75b88f
Merge pull request #49392 from akhilgkrishnan/active-record-notable-changes-1
[skip ci] ActiveRecord notable changes added to 7.1 release note
2023-09-26 13:41:16 -04:00
Ryuta Kamizono a86d4d7bbd Add a CHANGELOG entry for #49383
And restore updating old ones in the CHANGELOG.
2023-09-27 02:36:51 +09:00
Akhil G Krishnan 2022ee1be5 [skip ci] ActiveRecord notable changes added to 7.1 release note 2023-09-26 22:54:46 +05:30
Ian Candy a09fcd599d Removes unneccessary stub
We were reviewing this test while doing some work around transaction
tracking and noticed that the comment here seemed to no longer be the case.
`materialize_transactions` doesn't actually dirty the transaction anymore, so
it shouldn't be required to stub this out. Indeed, the tests continue to pass
without this method stub.

Co-authored-by: Daniel Colson <composerinteralia@github.com>
2023-09-26 13:03:50 -04:00
Rafael Mendonça França dc56140f56
Merge pull request #42429 from Flixt/fix-mysql-check-constraints-quoting
Fix duplicate escaping of quotes for check constraint expressions in MySQL schema
2023-09-26 12:34:43 -04:00
Rafael Mendonça França dcc6ad5497
Merge pull request #49370 from ghiculescu/upgrade-guide-rails-test
Upgrade guide: mention `test:prepare` enhnacements
2023-09-26 12:22:16 -04:00
Felix Tscheulin 468d3d0deb
Fix duplicate escaping of quotes for check constraint expressions in MySQL schema
Mysql automatically escapes quotes in generated check constraints expressions.
When Rails dumps the schema (into schema.rb) the generated schema also contains,
the quotes with duplicated escaping (\\\\').
To fix this, we remove the escaping, that MySQL provides from the fetched
expression.
2023-09-26 16:19:37 +00:00
Rafael Mendonça França cf44b9e3b3
Merge pull request #49272 from a5-stable/attachable-as-json
Fix as_json behavior in ActionText::Attachable
2023-09-26 12:13:32 -04:00
Rafael Mendonça França 15ccf5be96
Merge pull request #49387 from fractaledmind/ar-sqlite-7_1-release-notes
[skip ci] Add 7.1 release notes for SQLite3 adapter improvements
2023-09-26 12:03:13 -04:00
Rafael Mendonça França 5dfded9e33
Remove connection created in the test
This will avoid those connection leaking to other tests.

They cause problem because the fixtures loading will try to open
a transaction on all the active connections and since those connections
use a database pointing to a temp file that doesn't exist anymore
if any transaction try to start on them it will fail.

Fixes #49373.
2023-09-26 16:00:40 +00:00
a5-stable 7809146a03 fix ActionText::Attachable#as_json to allow options 2023-09-27 00:51:18 +09:00
Stephen Margheim 8c5584cf07 Add 7.1 release notes for SQLite3 adapter improvements 2023-09-26 16:09:05 +02:00
Eileen M. Uchitelle 05ed2610ce
Merge pull request #49386 from rails/revert-49096-document_class_method_scope_behavior
Revert "Document clean chain behavior for ActiveRecord scope"
2023-09-26 09:14:36 -04:00
zzak a564341537
Revert "Document clean chain behavior for ActiveRecord scope" 2023-09-26 20:44:22 +09:00
Ryuta Kamizono 4d42741a53 Fix typo "an unique" -> "a unique" [ci skip] 2023-09-26 19:58:49 +09:00
Ryuta Kamizono 708176efb0
Merge pull request #49383 from kamipo/rename_unique_constraint
Rename back unique keys to unique constraints
2023-09-26 18:35:14 +09:00
Ryuta Kamizono b2790b6680 Rename back unique keys to unique constraints
As we (I and @yahonda) talked about the naming in person, naming unique
constraints as unique keys is very confusing to me.
All documents and descriptions says it's unique constraints, but naming
unique keys leads to misunderstanding it's a short-hand of unique
indexes.
Just naming it unique constraints is not misleading.
2023-09-26 17:52:09 +09:00
Jess Brown c32813ddc6
Update description for filter_parameter_logging (#49347)
* Update description for filter_parameter_logging

* Update railties/lib/rails/generators/rails/app/templates/config/initializers/filter_parameter_logging.rb.tt

Thanks Rob!!. I did all this in the github ui and was a little out of sorts with the wrapping.

Co-authored-by: Rob Zolkos <rob@zolkos.com>

---------

Co-authored-by: Rob Zolkos <rob@zolkos.com>
Co-authored-by: Rafael Mendonça França <rafael@rubyonrails.org>
2023-09-25 23:21:03 -04:00
Rafael Mendonça França 92742751a9
Don't leak database connection to other tests 2023-09-26 01:59:13 +00:00
Rafael Mendonça França 3721fdce48
Remove erroneous committed file 2023-09-26 00:00:12 +00:00
Rafael Mendonça França 38ce7fa6b1
Merge pull request #48542 from ghiculescu/am-default-form-builder
Introduce `ActionMailer::FormBuilder`
2023-09-25 17:27:38 -04:00
Rafael Mendonça França 4c72cc2b04
Merge pull request #48615 from Edouard-chin/ec-logger
Add a public API for broadcasting logs
2023-09-25 17:13:58 -04:00
Rafael Mendonça França 88bb5f2749
Define the method in the right place 2023-09-25 21:04:41 +00:00
Rafael Mendonça França 4e605f5d0f
Fix ruby warning
Remove `.[]` before redefining it.
2023-09-25 20:47:36 +00:00
Edouard CHIN 1fbd812c47
Add a public API for broadcasting logs:
- ## Context

  While working on https://github.com/rails/rails/pull/44695, I
  realised that Broadcasting was still a private API, although it’s
  commonly used. Rafael mentioned that making it public would require
  some refactor because of the original implementation which was hard
  to understand and maintain.

  ### Changing how broadcasting works:

  Broadcasting in a nutshell worked by “transforming” an existing
  logger into a broadcasted one.
  The logger would then be responsible to log and format its own
  messages as well as passing the message along to other logger it
  broadcasts to.

  The problem with this approach was the following:

  - Heavy use of metaprogramming.
  - Accessing the loggers in the broadcast wasn’t possible.
    Removing a logger from the broadcast either.
  - More importantly, modifying the main logger (the one that broadcasts
    logs to the others) wasn’t possible and the main source of
    misunderstanding.

    ```ruby
      logger = Logger.new(STDOUT)
      stderr_logger = Logger.new(STDER))
      logger.extend(AS::Logger.broadcast(stderr_logger))

      logger.level = DEBUG # This modifies the level on all other loggers
      logger.formatter = … # Modified the formatter on all other loggers
    ```

  To keep the contract unchanged on what Rails.logger returns, the new
  BroadcastLogger class implement duck typing with all methods
  that has the vanilla Ruby Logger class.

  It's a simple and boring PORO that keeps an array of all the loggers
  that are part of the broadcast and iterate over whenever a log is
  sent.
  Now, users can access all loggers inside the broadcast and modify
  them on the fly. They can also remove any logger from the broadcast
  at any time.

  ```ruby
  # Before

  stdout_logger = Logger.new(STDOUT)
  stderr_logger = Logger.new(STDER)
  file_logger = Logger.new(“development.log”)
  stdout_logger.extend(AS::Logger.broadcast(stderr_logger))
  stdout_logger.extend(AS::Logger.broadcast(file_logger))

  # After

  broadcast = BroadcastLogger.new(stdout_logger, stderr_logger, file_logger)
  ```

  I also think that now, it should be more clear for users that the
  broadcast sole job is to pass everything to the whole loggers in
  the broadcast. So there should be no surprise that all loggers in
  the broadcast get their level modified when they call
  `broadcast.level = DEBUG` .

  It’s also easier to wrap your head around more complex setup such
  as broadcasting logs to another broadcast:
  `broadcast.broadcast_to(stdout_logger, other_broadcast)`
2023-09-25 20:40:51 +00:00
Alex Ghiculescu 9a2cf33f21
Introduce `ActionMailer::FormBuilder`
Fixes https://github.com/rails/rails/issues/48477

Using forms inside emails is not common, but it's possible, and it's also possible to share views between controllers and mailers. Currently if a controller sets a `default_form_builder` that's different from the global config, mailers that use the same views will not default to the same `FormBuilder`. To fix this, this PR adds a `default_form_builder` method for mailers that does the same thing as its controller sibling.
2023-09-25 20:33:22 +00:00
Rafael Mendonça França ad7a3e2d80
Merge pull request #49322 from hachi8833/add_tests_for_exclusion_validation2
[Docs][Tests] Add tests for validates_exclusion_of to 7.1.0beta1
2023-09-25 16:26:58 -04:00
Rafael Mendonça França 71613d3da9
Merge pull request #45411 from jonathanhefner/add-deep_mergeable
Factor out `deep_merge` into `AS::DeepMergeable`
2023-09-25 16:25:44 -04:00
Jean Boussier 2d196d4898
Merge pull request #49381 from dorianmariefr/fix-upload-of-files
Actually upload the files when passed as File or Pathname
2023-09-25 19:33:09 +02:00
Dorian Marié 94a7149a96 Actually upload the files when passed as File or Pathname
This is a follow-up to https://github.com/rails/rails/pull/45606

We were storing the file metadata in Blob and Attachment but we were not
actually uploading the files (into the file system for instance for disk
storage).

It was failing silently so I made it explicit what is accepted and what
is unexpected
2023-09-25 19:01:21 +02:00
Eileen M. Uchitelle f57d54cde4
Merge pull request #49336 from fatkodima/fix-mysql-expression-index-dumping
Fix MySQL expression index dumping with escaped quotes
2023-09-25 10:22:34 -06:00
Vipul A M d64e44b003
Merge pull request #49379 from akhilgkrishnan/code-highlight-fix
[skip ci] Missing language highligting added for bash code block
2023-09-25 21:47:10 +05:30
Akhil G Krishnan 14208d4d53 [skip ci] Missing language highligting added for bash code block 2023-09-25 21:25:33 +05:30
Jean Boussier adf1c2183f Fix an incorrect `assert_equal` argument order 2023-09-25 15:57:06 +02:00
Jean Boussier 94c90ecf20
Merge pull request #45606 from dorianmariefr/build-blob-from-file-or-pathname
Allow attaching File or Pathname to has_one_attached
2023-09-25 13:50:46 +02:00
Jean Boussier 99e2999f96
Merge pull request #48462 from iamradioactive/remove_additional_query
Do not revalidate encrypted attribute with current encrypted_type
2023-09-25 13:50:07 +02:00
Dorian Marié 22bacd710d Allow attaching File or Pathname to has_one_attached
### Why was this change necessary?

When creating models in tests, it's easier to pass a File or a Pathname
(from `file_fixture` for instance) to `Model.create` for instance

### How does it address the problem?

When attaching an attachable, we check if it's a File or a Pathname and
handle it appropriately.
2023-09-25 13:43:26 +02:00
Xavier Noria 44d0859904 Minor edits in the upgrading guide 2023-09-25 11:45:47 +02:00
Ryuta Kamizono e35e78020f
Merge pull request #49372 from skipkayhil/hm-rm-safe-level-requires
Update requires in LoggerThreadSafeLevel
2023-09-25 12:06:22 +09:00
Hartley McGuire 162be9f219
Merge pull request #49350 from bhanubhakta/bhanubhakta-include-hidden-file-field-docs
Update doc for `include_hidden` form form file_field.
2023-09-24 22:16:28 -04:00
Hartley McGuire 0f5e7a6614
Update requires in LoggerThreadSafeLevel
The `concurrent` require was [added][1] previously because a
`Concurrent::Map` was added to hold all of the log levels by `Thread` id.
However, the `Map` was later [removed][2] by storing the log levels in the
`Thread` locals (and later in `IsolatedExecutionState`) instead. The new
implementation additionally removed the `cattr_accessor` (removing the
need to require the "attribute_accessors" core_ext) and also replaced
the [usage][3] of `Fiber` with `Thread` (so the require for `Fiber` is also no
longer necessary).

Since `Concurrent`, `Fiber`, and `cattr_accessor` are no longer used here, we
can remove the requires. Since `Logger` is used here (but was previously
required by `concurrent`), a require was added for it.

[1]: 629efb6057
[2]: 2379bc5d2a
[3]: 56ec504db6
2023-09-24 21:59:55 -04:00