Commit Graph

90426 Commits

Author SHA1 Message Date
Dorian Marié 420b19a255 Upgrade minitest from 5.20.0 to 5.21.1 to fix mutex_m deprecation 2024-01-12 16:49:20 +01:00
Jean Boussier c6ef898246 Remove an unused fixture
Mistakenly added in https://github.com/rails/rails/pull/50594
2024-01-11 09:27:30 +01:00
Jonathan Hefner 91968e5a18 Do not mask NoMethodError for render_in in render_in
Follow-up to #50699.

This prevents a `NoMethodError` from being masked when the missing
method is itself named `render_in`.

Co-authored-by: Hartley McGuire <skipkayhil@gmail.com>
2024-01-10 17:26:27 -06:00
Jonathan Hefner c66b655bf8
Merge pull request #50699 from jonathanhefner/follow-up-50665
Do not mask `NoMethodError` from within `render_in`
2024-01-10 13:46:40 -06:00
Jonathan Hefner 952a13b0ac Do not mask NoMethodError from within render_in
Follow-up to #50665.

Unconditionally converting `NoMethodError` to `ArgumentError` can mask a
legitimate `NoMethodError` from within the `render_in` method.  This
commit adds a check to prevent that.
2024-01-10 13:37:37 -06:00
Jean Boussier b83827a81f
Merge pull request #50698 from byroot/delegate-reduce-fstring
`Module#delegate` avoid creating a unique fstring for each delegator
2024-01-10 19:59:38 +01:00
Rafael Mendonça França 75ba520b29
Merge pull request #49678 from seanpdoyle/remove-unnecessary-method-from-attribute-assignment
Remove `ActiveRecord::AttributeAssignment#assign_nested_parameter_attributes`
2024-01-10 13:39:17 -05:00
Jean Boussier 4bded3c00a `Module#delegate` avoid creating a unique fstring for each delegator
For example:

```ruby
delegate :negative?, to: :value, as: Numeric
```

Before:

```
def negative?(&block)
  _ = @value
  _.negative?(&block)
rescue NoMethodError => e
  if _.nil? && e.name == :negative?
    raise DelegationError, "ActiveSupport::Duration#negative? delegated to @value.negative?, but @value is nil: #{self.inspect}"
  else
    raise
  end
end
```

After:

```ruby
def negative?(&block)
  _ = @value
  _.negative?(&block)
rescue NoMethodError => e
  if _.nil? && e.name == :negative?
    raise DelegationError.nil_target(:negative?, :"@value")
  else
    raise
  end
end
```

Before almost every delegator would generate a large unique string that gets interned for
the error message that is rarely if ever used.

Rather than to "hardcode" a unique string, we now only pass pre-existing symbols to
a method helper that will build the error message.

This alone saves about 160B per delegator, and the method bytecode is also marginally
smaller (but it's harder to assess how much this actually saves)
2024-01-10 19:27:50 +01:00
Jean Boussier 9dab3e4184 Fix a typo in puma.rb.tt 2024-01-10 18:42:14 +01:00
Sean Doyle ded026b6c9 Remove `ActiveRecord::AttributeAssignment#assign_nested_parameter_attributes`
The private `#assign_nested_parameter_attributes` was introduced in
[774ff18][] (Dec 15, 2011), moved to `ActiveRecord::AttributeAssignment`
in [ceb33f8][] (also Dec 15, 2011), then most recently modified in
[2606fb3][] (Jan 23, 2015) when `ActiveModel::AttributeAssignment` was
extracted.

Support for `accepts_nested_attributes_for` (introduced in [ec8f045][]
Feb 1, 2009) pre-dates those commits, and has evolved enough to cover
this behavior in other ways.

With its removal, Active Record's test suite still passes, so if it's a
crucial piece of code to retain, we should expand the suite to exercise
it.

[774ff18]: 774ff18c09
[ceb33f8]: ceb33f8493
[2606fb3]: 2606fb3397
[ec8f045]: ec8f045844
2024-01-10 07:36:09 -05:00
Jean Boussier eac48e95db
Merge pull request #50669 from byroot/update-puma-defaults
Update the default Puma configuration
2024-01-10 11:16:51 +01:00
Jean Boussier 06d614ada9 Update the default Puma configuration
The main change is the default number of threads
is reduced from 5 to 3 as discussed in https://github.com/rails/rails/issues/50450

Pending a potential future "Rails tuning" guide, I tried
to include in comments the gist of the tradeoffs involved.

I also removed the pidfile except for development.
It's useful to prevent booting the server twice there
but I don't think it makes much sense in production,
especially [since Puma no longer supports daemonization
and instead recommend using a process
monitor](99f83c50fb/docs/deployment.md (should-i-daemonize)).
And it makes even less sense in a PaaS or containerized
world.
2024-01-10 10:13:59 +01:00
Jean Boussier 61b48fe76d
Merge pull request #50686 from seanpdoyle/remove-current-attributes-method-missing
Avoid definition of methods at runtime in `CurrentAttributes`
2024-01-10 09:40:09 +01:00
Sean Doyle c8e5b0b531 Avoid definition of methods in `CurrentAttributes` at runtime
Replacing on the fly a `method_missing` by a generated method
sound like a nice trick, but it's not as good as it sound for
optimization, as the method will be generated by the first
request to use it, preventing the ISeq from being is shared memory.

Instead we can eagerly define a delegator when instance methods
are defined, and keep a regular `method_missing + send` for the
very rare cases not covered.

Co-Authored-By: Jean Boussier <jean.boussier@gmail.com>
2024-01-10 08:59:35 +01:00
Jean Boussier 31a341e754
Merge pull request #50689 from akhilgkrishnan/ignore-files-in-dockerignore
Ignore docker and git related files in dockerignore
2024-01-10 08:52:33 +01:00
Jean Boussier 2b776fad28
Merge pull request #50664 from ghiculescu/global_executor_concurrency-example
Add an example to the `global_executor_concurrency` docs
2024-01-10 08:51:16 +01:00
Akhil G Krishnan de3a9a1d41 Ignore docker and git related files in dockerignore
Ignore docker and git related files in dockerignore

Ignore docker and git related files in dockerignore
2024-01-10 11:22:19 +05:30
Rafael Mendonça França 1db9705396
Merge pull request #50677 from seanpdoyle/current-attributes-defaults
Add `default:` support for `ActiveSupport::CurrentAttributes.attribute`
2024-01-09 19:43:37 -05:00
Sean Doyle d1d6b6bce3 Add `default:` support for `ActiveSupport::CurrentAttributes.attribute`
Extend the `.attribute` class method to accept a `:default` option for
its list of attributes:

```ruby
class Current < ActiveSupport::CurrentAttributes
  attribute :counter, default: 0
end
```

Internally, `ActiveSupport::CurrentAttributes` will maintain a
`.defaults` class attribute to determine default values during instance
initialization.
2024-01-09 19:09:57 -05:00
Rafael Mendonça França beb6214bb0
Merge pull request #50674 from p8/activerecord/document-sum-with-block
Document `Calculations#count` and `Calculations#sum` block arguments …
2024-01-09 19:08:04 -05:00
Rafael Mendonça França cdfca904a1
Merge pull request #50675 from gareth/remove-redundant-restricted-class-method
Remove redundant `parent` method from RESTRICTED_CLASS_METHODS
2024-01-09 19:05:46 -05:00
Rafael Mendonça França e786865506
Merge pull request #50339 from seanpdoyle/action-dispatch-show-exceptions-upgrading-docs
Document developer-facing change to `config.action_dispatch.show_exceptions` default
2024-01-09 18:35:51 -05:00
Sean Doyle 723e69c857 Document developer-facing change to config.action_dispatch.show_exceptions default
Support for the new `action_dispatch.show_exceptions` values was
introduced in [e28f147][]. Alongside the change to introduce new values
(like `:all`, `:rescuable`, `:none`), the default behavior was changed
for `Rails.env.test?`.

Prior to that commit, the `test` environment's default value was `false`
(introduced in [d898a4b][]) (which corresponds to the new `:none`
setting).

The new default behavior has some unintended negative side effects that
impact the feedback loop at the core of test-driven development.
When errors are rescued and transformed into HTML pages, the context of
the cause of failure is obscured by additional layers of information.

First, this commit adds more prominent entries to the Upgrading and
Configuring guides, as well as the 7.1 Release Notes to document the
details of the configuration and its new values.

Next, this commit adds more documentation around the change in default
behavior. To start, it mentions the new value in the sections for the
affected test types: Controller, Integration, and System.

[e28f147]: e28f147329
[d898a4b]: d898a4ba42
2024-01-09 18:08:28 -05:00
Jean Boussier dcd13fc8ee Relock Gemfile on Ruby 3.3.0
Google hasn't shipped precompile binaries
for Ruby 3.3.0 yet, so it confuses bundler...
2024-01-09 23:58:10 +01:00
Jean Boussier c144c4868b
Merge pull request #50685 from seanpdoyle/current-attributes-instance-delegation
Simplify `CurrentAttribute.instance` delegation
2024-01-09 23:32:25 +01:00
Rafael Mendonça França f3d96c2aa4
Merge pull request #50665 from seanpdoyle/action-view-renderable-argument-error
Raise `ArgumentError` if `:renderable` object does not respond to `#render_in`
2024-01-09 17:03:24 -05:00
Sean Doyle 2cd4abcc87 Simplify `CurrentAttribute.instance` delegation
Follow-up to [#50676][]

Instead of relying on code generation, call a corresponding [delegate][]
method on the `.singleton_class`.

[#50676]: https://github.com/rails/rails/pull/50676
[delegate]: https://edgeapi.rubyonrails.org/classes/Module.html#method-i-delegate

Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2024-01-09 16:54:00 -05:00
Sean Doyle b3bb06a24a Raise `ArgumentError` if `:renderable` object does not respond to `#render_in`
When calling `render` with a `:renderable` argument, ensure that the
object responds to `#render_in`. If it doesn't, raise an
`ArgumentError`.

This commit also adjusts the `ArgumentError` that when a `:partial`
argument isn't Active Model compatible. Prior to this commit, the
message used `:` as a prefix to `to_partial_path`. This commit replaces
that with a `#` prefix to denote that it's expected to be an instance
method on the object.
2024-01-09 16:01:04 -05:00
fatkodima ba2603ac0d
Merge pull request #50682 from p8/activerecord/readonly-examples
Add code examples to `readonly` documentation [skip ci]
2024-01-09 22:40:54 +02:00
fatkodima 21648f4319
Merge pull request #50683 from p8/activerecord/configurations-docs-typo
Fix typo in ActiveRecord::Core.configurations doc [ci-skip]
2024-01-09 22:24:31 +02:00
Petrik 9ba7e53f68 Document `Calculations#count` and `Calculations#sum` block arguments [ci-skip] 2024-01-09 21:23:14 +01:00
Petrik 64b24171c4 Add code examples to `readonly` documentation 2024-01-09 21:22:10 +01:00
Petrik c0dc61c59a Fix typo in ActiveRecord::Core.configurations doc [ci-skip] 2024-01-09 21:21:20 +01:00
Rafael Mendonça França 7edf988d6c
Merge pull request #50678 from seanpdoyle/current-attributes-with
Implement `CurrentAttributes#set` in terms of `Object#with`
2024-01-09 15:19:47 -05:00
Rafael Mendonça França d8cb2e94f1
Remove the Gemfile.lock for good now 2024-01-09 19:56:58 +00:00
Rafael Mendonça França 18501f7c6c
Don't use the Gemfile lock on CI steps
This file is only for development.
2024-01-09 19:54:02 +00:00
Rafael Mendonça França b1479e412d
Remove redundant version constraint on mail gem 2024-01-09 19:41:52 +00:00
Sean Doyle 3c72983dc5 Implement `CurrentAttributes#set` in terms of `Object#with`
`CurrentAttributes` supports block-scoped overrides for its attributes
through the `#set` method. The introduction of [CurrentAttributes#set][]
predates the introduction of [Object#with][] by 6 years.

This commit changes the implementation of `#set` to delegate to `#with`.
Through that delegation, the private `#assign_attributes` and
`#compute_attributes` methods are no longer necessary.

[CurrentAttributes#set]: 2d6b02bad6/activesupport/lib/active_support/current_attributes.rb (L210)
[Object#with]: 2d6b02bad6/activesupport/lib/active_support/core_ext/object/with.rb (L26)
2024-01-09 14:34:18 -05:00
Gareth Adams f705c39fa4 Remove redundant `parent` method from RESTRICTED_CLASS_METHODS
Previously, `parent` was added as one of the RESTRICTED_CLASS_METHODS as
part of a commit (94b7328b08) in 2014 that stopped Rails `enum`s from being
able to redefine important class methods.

At the time, Rails monkey-patched `Module` with a `parent` class method
that returned a module's containing module if it was nested.

However, in October 2020 (167b4153ca) in Rails 6.1, this method was
deprecated in favour of a renamed method `module_parent`. As such, the
`parent` method doesn't need to be a restricted class method any more.
2024-01-09 16:07:39 +00:00
Jean Boussier 2d6b02bad6
Merge pull request #50632 from skipkayhil/hm-move-chunk-test-to-actionpack
Move Transfer-Encoding chunked test to Action Pack
2024-01-09 14:35:50 +01:00
Jean Boussier 3c19732ded
Merge pull request #50657 from akhilgkrishnan/remove-codespell-from-ci
Remove codespell step from CI
2024-01-09 14:34:27 +01:00
Jean Boussier c67d6bffad
Merge pull request #50667 from akhilgkrishnan/remove-blank-link-in-ci
Fix extra blank line on CI when skipping brakeman
2024-01-09 14:33:21 +01:00
Jean Boussier a30e3ba854
Merge pull request #50668 from Earlopain/clean-mail-dependencies
Remove workaround for `mail` gem dependencies
2024-01-09 14:32:45 +01:00
Earlopain 45f64f5a0a
Remove workaround for `mail` gem dependencies
d9d8dcc6ba
https://github.com/rails/rails/pull/44083

Remove backwards compat workaround for versions earlier than 2.8.0
2024-01-09 13:25:36 +01:00
Jean Boussier fc75fed35a
Merge pull request #50670 from byroot/active-support-after-fork-check
Get rid of `ForkTracker.check!`
2024-01-09 13:20:39 +01:00
Yasuo Honda df943c8f7c
Merge pull request #50432 from fatkodima/better-docs-for-add_exclusion_constraint
Document missing `:using` and `:where` options for `add_exclusion_constraint` [skip ci]
2024-01-09 19:55:37 +09:00
Jean Boussier a3d05309aa Get rid of `ForkTracker.check!`
Now that we require Ruby 3.1, we can assume `Process._fork` is
defined on MRI, hence we can trust that our decorator will
reliably detect forks so we no longer need to check the if
the pid changed in critical spots.
2024-01-09 11:18:38 +01:00
Akhil G Krishnan dbdc26858a Fix extra blank line on CI when skipping brakeman
Fix extra blank line on CI when skipping brakeman

Fix extra blank line on CI when skipping brakeman
2024-01-09 12:26:17 +05:30
Alex Ghiculescu a40bb8eb8f Expand on global_executor_concurrency docs 2024-01-09 16:03:54 +10:00
Akhil G Krishnan 7812ab1138 Remove codespell step from CI
removed codespell.txt
2024-01-09 09:27:13 +05:30