Commit Graph

88756 Commits

Author SHA1 Message Date
Rafael Mendonça França
90bdbe0645
Merge pull request #49026 from akhilgkrishnan/release_note_docker
Add default docker files description to 7.1 release note [skip ci]
2023-08-24 14:54:10 -04:00
Akhil G Krishnan
3146a1c360 Add default docker files description to 7.1 release note
Added the review changes

review changes updated
2023-08-24 21:46:44 +05:30
Rafael Mendonça França
1c3aed0442
Merge pull request #49022 from akhilgkrishnan/release_7_1_railties
[skip ci] Added changes of railties to release notes for 7.1
2023-08-24 12:12:44 -04:00
Akhil G Krishnan
25e0fabe53 Added changes of railties to release notes for 7.1
review changes updated
2023-08-24 21:33:46 +05:30
Rafael Mendonça França
4df85d7089
Merge pull request #49029 from technicalpickles/abstractcontroller_base-action_methods-performance
Improve performance of AbstractController::Base#action_methods
2023-08-24 11:41:04 -04:00
Rafael Mendonça França
57b79cf162
Improve guide for Customizing form builder
Make the example complete so people can follow along insted of having
to understand the implicit context that you need an existing helper
called `text_field_with_label` to make the example work.

Fixes #49027.
2023-08-24 15:32:01 +00:00
Rafael Mendonça França
dc3da021ee
Fix comments and indentation 2023-08-24 15:22:34 +00:00
Josh Nichols
b2afa8b3fb
Improve performance of AbstractController::Base#action_methods
I was benchmarking some specs in my app, and saw this code come up in the
memory_profiler. It is by no means the biggest memory allocation, but it
is straightforward to make a slight improvement.

Primarily, this saves allocating one array by using concat instead of +
to add public_instance_methods(false).

That ends up being 10% less memory for my benchmark (3 actions), and 6%
faster.

```
Calculating -------------------------------------
            original     8.352k memsize (   208.000  retained)
                        22.000  objects (     2.000  retained)
                         6.000  strings (     0.000  retained)
         refactored3     7.616k memsize (   408.000  retained)
                        11.000  objects (     7.000  retained)
                         3.000  strings (     3.000  retained)

Comparison:
         refactored3:       7616 allocated
            original:       8352 allocated - 1.10x more
Warming up --------------------------------------
            original     2.326k i/100ms
         refactored3     2.441k i/100ms
Calculating -------------------------------------
            original     23.336k (± 0.7%) i/s -    118.626k in   5.083658s
         refactored3     24.692k (± 1.2%) i/s -    124.491k in   5.042345s

Comparison:
            original:    23336.0 i/s
         refactored3:    24692.5 i/s - 1.06x  faster
```

Benchmark and results are also posted to https://gist.github.com/technicalpickles/4a4ae6a9e2c42963af43a89f75e768fe
2023-08-24 09:30:50 -04:00
Jean Boussier
4bbb59c514
Merge pull request #49028 from akhilgkrishnan/move-sh-to-bash
[skip ci] Moved sh to bash and added missing $
2023-08-24 15:22:14 +02:00
Akhil G Krishnan
0f7f9e3d5e [skip ci] Moved sh to bash and added missing $ 2023-08-24 18:48:20 +05:30
Jean Boussier
a6f86243af
Merge pull request #49024 from byroot/nodoc-source-map
Add some :nodoc: to SyntaxErrorProxy and friends
2023-08-24 11:51:13 +02:00
Jean Boussier
6beb15c04a Add some :nodoc: to SyntaxErrorProxy and friends
None of this is public API.
2023-08-24 09:52:18 +02:00
Rafael Mendonça França
8b095c8647
Merge pull request #49021 from Shopify/update-undefine-attribute-methods-docs
[Docs] Update `undefine_attribute_methods` docs
2023-08-23 18:11:51 -04:00
Rafael Mendonça França
d70707d9af
Merge pull request #49020 from Shopify/allow-redefining-to-param-delimiter
Allow redefining `to_param` delimiter using `param_delimiter`
2023-08-23 18:11:14 -04:00
Nikita Vasilevsky
5bc904d37d
[Docs] Update undefine_attribute_methods docs 2023-08-23 22:02:49 +00:00
Rafael Mendonça França
59542e86c4
Merge pull request #49019 from adrianna-chang-shopify/ac-deprecate-read-attribute-id-pk
Deprecate `read_attribute(:id)` returning the primary key
2023-08-23 18:02:36 -04:00
Rafael Mendonça França
c70ac1d9eb
Merge pull request #49012 from skipkayhil/hm-migration-table-def-methods
Ensure all migration versions use TableDefinition
2023-08-23 17:59:41 -04:00
Nikita Vasilevsky
564a3d6d97
Support composite primary key in AR::Base#to_param 2023-08-23 21:53:47 +00:00
Nikita Vasilevsky
37342a37fd
Allow redefining to_param delimiter using param_delimiter
This commit allows customizing the delimiter used by `to_param` when
`to_key` returns multiple value. This unblocks supporting more varieties
of composite primary key types in Active Record.
2023-08-23 20:49:22 +00:00
Adrianna Chang
ac83311bae
Deprecate read_attribute(:id) returning the primary key
This commit deprecates `read_attribute(:id)` returning the primary key
if the model's primary key is not the id column. Starting in Rails 7.2,
`read_attribute(:id)` will always return the value of the id column.

This commit also changes `read_attribute(:id)` for composite primary
key models to return the value of the id column, not the composite
primary key.
2023-08-23 16:36:32 -04:00
Rafael Mendonça França
dd6d9314b2
Merge pull request #49001 from seanpdoyle/html-parsed-body-release-notes
Document `response.parsed_body` in 7.1 release notes
2023-08-23 16:00:00 -04:00
Oscar Romero
9db860f1b4
Document the :ignore_date option on time_select (#49017)
* Document the :ignore_date option on time_select

* split documentation comment into two lines

Co-authored-by: Rafael Mendonça França <rafael@franca.dev>
2023-08-23 15:41:53 -04:00
Sean Doyle
90c901137f Document response.parsed_body in 7.1 release notes
Add notes for [#47144][] to the 7.1 Release Notes.

Additionally, in the time since that was merged, both Nokogiri and
Minitest have merged the PRs mentioned to integrate support for Ruby's
Pattern matching (https://github.com/sparklemotion/nokogiri/pull/2523
and https://github.com/minitest/minitest/pull/936, respectively).

This commit adds coverage for those new assertions, and incorporates
guidance into the release notes.

[#47144]: https://github.com/rails/rails/pull/47144
2023-08-23 15:33:52 -04:00
Rafael Mendonça França
c18bcd5828
Keep VariantWithRecord API consistent with Variant
The `process` and `processed?` methods in Variant are private.
2023-08-23 19:16:39 +00:00
Rafael Mendonça França
144dd24c05
Merge pull request #48999 from higher-pixels/activestorage-transformjob-nomethoderror
Fix NoMethodError in ActiveStorage::TransformJob for untracked variants.
2023-08-23 15:05:56 -04:00
Rafael Mendonça França
818bfc269a
Remove deprecation messages from actionpack test suite
The 6.1 cache format that is the default is deprecated.
2023-08-23 18:43:35 +00:00
Rafael Mendonça França
3a680cd647
Merge pull request #49015 from Shopify/update-changelong-about-undefine-attribute-methods
Add new behavior of `undefine_attribute_methods` to CHANGELOG
2023-08-23 14:38:39 -04:00
Rafael Mendonça França
a7a1217cd4
Merge pull request #49003 from seanpdoyle/test-response-parsed-body-pattern-matching
Ensure `response.parsed_body` support for pattern matching
2023-08-23 14:02:40 -04:00
Sean Doyle
0f4ab82082 Ensure response.parsed_body support for pattern matching
Both `Nokogiri` and `Minitest` have merged the PRs mentioned to
integrate support for Ruby's Pattern matching
(https://github.com/sparklemotion/nokogiri/pull/2523 and
https://github.com/minitest/minitest/pull/936, respectively).

This commit adds coverage for those new assertions, and incorporates
examples into the documentation for the `response.parsed_body` method.

In order to incorporate pattern-matching support for JSON responses,
this commit changes the response parser to call `JSON.parse` with
[object_class: ActiveSupport::HashWithIndifferentAccess][object_class],
since String instances for `Hash` keys are incompatible with Ruby's
syntactically pattern matching.

For example:

```ruby
irb(main):001:0> json = {"key" => "value"}
=> {"key"=>"value"}
irb(main):002:0> json in {key: /value/}
=> false

irb(main):001:0> json = {"key" => "value"}
=> {"key"=>"value"}
irb(main):002:0> json in {"key" => /value/}
.../3.2.0/lib/ruby/gems/3.2.0/gems/irb-1.7.4/lib/irb/workspace.rb:113:in `eval': (irb):2: syntax error, unexpected terminator, expecting literal content or tSTRING_DBEG or tSTRING_DVAR or tLABEL_END (SyntaxError)
json in {"key" => /value/}
             ^

        .../ruby/3.2.0/lib/ruby/gems/3.2.0/gems/irb-1.7.4/exe/irb:9:in `<top (required)>'
        .../ruby/3.2.0/bin/irb:25:in `load'
        .../ruby/3.2.0/bin/irb:25:in `<main>'
```

When the Hash maps String keys to Symbol keys, it's able to be pattern
matched:

```ruby
irb(main):005:0> json = {"key" => "value"}.with_indifferent_access
=> {"key"=>"value"}
irb(main):006:0> json in {key: /value/}
=> true
```

[object_class]: https://docs.ruby-lang.org/en/3.2/JSON.html#module-JSON-label-Parsing+Options
2023-08-23 13:28:02 -04:00
Nikita Vasilevsky
e50fce0fa9
Add new behavior of undefine_attribute_methods to CHANGELOG
In `1818beb3a3ea5fdb498095d4885f8a7e512f24ca` Rails changed the target
where alias attribute methods are defined. It lead to
`undefine_attribute_methods` to clean alias attribute methods along with
the attribute methods. It was an intended behavior change but it wasn't
properly documented and tested. This commit clarifies the new behavior
in the Active Model changelog along with covering the behavior with tests.
2023-08-23 14:41:10 +00:00
Adrianna Chang
a5f64bf29d
Merge pull request #49004 from andrewn617/improve-base-class-documentation
Improve the documentation for ActiveRecord::Inheritance#base_class
2023-08-23 09:36:12 -04:00
Andrew Novoselac
46279956cf Improve the documentation for ActiveRecord::Inheritance#base_class 2023-08-23 09:19:40 -04:00
Jean Boussier
be2c6320f1
Merge pull request #48996 from Shopify/check-for-parent-being-an-owner-of-the-target-method
Allow parent being the owner of an alias attribute method
2023-08-23 14:33:00 +02:00
Nikita Vasilevsky
0c99588919
Allow parent being the owner of an alias attribute method
When an abstract class inherited from an Active Record model
defines an alias attribute Rails should expect the original methods
of the aliased attribute to be defined in the parent class and avoid
raising deprecation warning.
2023-08-23 11:35:45 +00:00
Jean Boussier
5544a81302
Merge pull request #49014 from akhilgkrishnan/add-missing-dollar
[skip ci] Added missing $ for a bash
2023-08-23 12:41:45 +02:00
Akhil G Krishnan
d104005053 [skip ci] Added missing $ for a bash script 2023-08-23 15:58:08 +05:30
Hartley McGuire
c793cdc665
Ensure all migration versions use TableDefinition
This is similar to a [previous commit][1] which ensures that versioned
migrations always call `super` in `compatible_table_definition`. In this
case, these methods are being pulled up to `Current` so that all
subclasses will use a `TableDefinition` class and future developers do
not have to remember to add all of these methods to new versioned
classes when a new one is created.

[1]: 16f8bd79444a512dfebf2d77bd2fd3075041475b
2023-08-23 02:03:31 -04:00
Matthew Draper
ec67f71b33
Merge pull request #49008 from zzak/workflows-rubocop-bundle_only
Use zzak/action-discord@v8
2023-08-23 11:07:10 +09:30
Yasuo Honda
2c5bfbd397
Merge pull request #48974 from skipkayhil/hm-fix-change-table-precision
Fix 6.1 change_table setting datetime precision
2023-08-23 10:29:04 +09:00
zzak
9218ef7c65
Use zzak/action-discord@v8
* Removed 'fixed/still failing' modes
* Only runs when failure() step
* Include GITHUB_TOKEN to prevent rate-limits
* Need to reset BUNDLE_ONLY on rubocop job
2023-08-23 10:09:57 +09:00
Hartley McGuire
9b07b2d6ca
Fix 6.1 change_table setting datetime precision
While working on #48969, I found that some of the Compatibility test
cases were not working correctly. The tests removed in this commit were
never running the `change_table` migration and so were not actually
testing that `change_table` works correctly. The issue is that the two
migrations created in these tests both have `nil` versions, and so the
Migrator only runs the first one.

This commit refactors the tests so that its easier to test the behavior
of each Migration class version (and I think the rest of the tests
should be updated to use this strategy as well). Additionally, since the
tests are fixed it exposed that `t.change` in a `change_table` is not
behaving as expected so that is fixed as well.
2023-08-22 14:01:52 -04:00
Rafael Mendonça França
ed5af00459
Merge pull request #48998 from Shopify/to_key-supports-composite-primary-key
Support composite identifiers in `to_key`
2023-08-22 13:53:19 -04:00
Aaron Patterson
3338621efa
Use a temporary file for storing unencrypted files while editing
When we're editing the contents of encrypted files, we should use the
`Tempfile` class because it creates temporary files with restrictive
permissions.  This prevents other users on the same system from reading
the contents of those files while the user is editing them.

[CVE-2023-38037]
2023-08-22 10:23:15 -07:00
Bryan Traywick
1d212dc357 Fix NoMethodError in ActiveStorage::TransformJob for untracked variants. 2023-08-22 13:01:44 -04:00
Nikita Vasilevsky
8a5cf4cf44
Support composite identifiers in to_key
This commit adds support for composite identifiers in `to_key`.
Rails 7.1 adds support for composite primary key which means that
composite primary key models' `#id` method returns an `Array` and
`to_key` needs to avoid double-wrapping the value.
2023-08-22 16:13:23 +00:00
Jean Boussier
5f6c404853
Merge pull request #48983 from JoeDupuis/fix-regression-on-strict-has-one-through
Fix regression blocking creation of some strict association
2023-08-22 17:20:56 +02:00
Jean Boussier
40d761c3e1
Merge pull request #48987 from Austio/better-dom-id-error-on-nil
Adds a specific ArgumentError when passing nil to dom_id.
2023-08-22 17:19:45 +02:00
Austin Story
6245c0048a Adds a specific ArgumentError when passing nil to dom_id. Which can happen if you do something like pass a non-existent ivar dom_id(@something_non_existant)
Before this would raise: `NoMethodError: undefined method `to_key' for nil:NilClass`
After it raises `ArumentError: dom_id must be passed a record_or_class as the first parameter, you passed 'nil'`
2023-08-22 17:16:25 +02:00
Yasuo Honda
e98a6bda09
Merge pull request #48969 from skipkayhil/hm-fix-change-column-precision
Fix 6.1 change_column setting datetime precision
2023-08-22 17:28:41 +09:00
Matthew Draper
36ebb6ba2d
Merge pull request #48919 from zzak/actions-refactor
Refactor actions to make fewer status checks
2023-08-22 14:05:05 +09:30