Followup: https://github.com/rails/rails/pull/50923
Instead of stopping on the first frame that isn't in
Action Dispatch, we should return the first frame that
isn't filtered by the backtrace cleaner.
The following was added to the `ActiveJob::Callbacks`,
`ActiveModel::Callbacks` and `AbstractController:Callbacks` docs
in #29072:
> NOTE: Calling the same callback multiple times will overwrite
> previous callback definitions.
The comment refers to "calling" callbacks but seems to be about defining
callbacks, as mentioned in the PR description.
In the ActiveJob and AbstractController docs, I believe this will be
misinterpreted as referring to setting callbacks, which, as far as I can
tell, does not have such a restriction.
In the ActiveModel docs, I believe it would be slightly clearer to
replace "calling" with "defining".
Given that the limiter implementation provided by Kredis is a simple
increment with a limit, all `ActiveSupport::Cache` already provide that
same capability, with a wide range of backing stores, and not just Redis.
This even allow to use SolidCache has a backend if you so desire.
If we feel particularly fancy, we could also accept a more generic
limiter interface to better allow users to swap the implementation
for better algorithms such as leaky-bucket etc.
Previously, it was theoretically possible to define a route with a
Symbol as a `to:` value (or at least, it would not raise a
`NoMethodError`). However, passing a Symbol broke when `/#/.match?(to)`
was [replaced][1] with `to&.include?("#")` with the assumption that `to`
was always a String.
Instead of restoring the previous error, this commit improves how the
`to:` value is checked so that it raises an `ArgumentError` for any
invalid values. The extra strictness will specifically improve the error
when a Symbol or String that doesn't include a "#" are passed since they
were effectively equivalent to passing a `nil` value, or not specifying
`to:` at all.
[1]: 5726b1d1d7
While working on [another PR][1], I found that removing the
Transfer-Encoding conditionals did not result in any failing tests in
Action Pack. This was surprising to me until I found that there was a
test for this behavior in Railties. However, nothing about the test
really depends on having a full Rails application or the Railties test
suite.
This commit moves the test into Action Pack to simplify/speedup the test
(no need to build a full app) as well as keeping the test closer to the
actual behavior being tested.
[1]: 0c334b48fdc5d70b0c8406ba184fbfd26750b049
We recently had [two][1] [PRs][2] to update these types of links, so
this commit does all of the rest (remaining links to master branches
were checked and still exist).
[1]: e76c52a939
[2]: a2ed3437e3
Provide examples for rendering objects that respond to `render_in`. Also
highlight that the object can also define a `#format` method to control
how the rendered String should be treated.
Add test coverage for both Action View's and Action Pack's support for
`render` with `:renderable` options.
Now that we dropped support for Ruby 2.7, we no longer
need to check if variables are defined before accessing them
to avoid the undefined variable warning.
Now that we no longer support Ruby 2.7, many `ruby2_keyword` calls
can be eliminated.
The ones that are left could be eliminated but would end up substantially
slower or more compliacated so I left them for now.
Also perform two autocorrects with `bundle exec rubocop -A`:
- fixes a new case of [`Style/RedundantReturn`][1]
- fixes a new case of [`Performance/StringInclude`][2]
[1]: 146b1c2e33
[2]: 3158bbb9f6
Co-authored-by: David Heinemeier Hansson <david@basecamp.com>
Until now, Rails only droped compatibility with older
rubies on new majors, but I propose to change this policy
because it causes us to either keep compatibility with long
EOLed rubies or to bump the Rails major more often, and to
drop multiple Ruby versions at once when we bump the major.
In my opinion it's a bad alignments of incentives. And we'd
be much better to just drop support in new minors whenever they
go EOL (so 3 years).
Also Ruby being an upstream dependency, it's not even
a semver violation AFAICT.
Since Rails 7.2 isn't planned before a few months, we
can already drop Ruby 3.0 as it will be EOL in March.
Follow-up to #46530.
The dynamically generated `url_helpers` module is an
`ActiveSupport::Concern`. Therefore, when it is included directly in
another `ActiveSupport::Concern`, its `included` block is deferred until
the latter concern is itself included elsewhere. Thus, in that case,
the call to `base._routes` in `def self.included(base)` will raise
`NoMethodError` because the `included` block will not yet have defined
the `_routes` method.
This commit prevents the error by first checking if `base` responds to
`_routes`.
Rack was recently [updated][1] with a deprecation for some status codes
that have been renamed (most notably, Unprocessable Entity was renamed
to Unprocessable Content). Since the deprecation was only added to
the `#status_code` method, this has caused test failures for some tests
that depend on the `SYMBOLS_TO_STATUS_CODE` hash.
This commit replaces the usage of `SYMBOLS_TO_STATUS_CODE` with
`#status_code` so that we get the deprecation message instead of a test
failure.
[1]: 64ad26e338
Follow-up to #49908.
When Selenium resolves the driver path to a copy of Chrome that it has
downloaded / cached, it mutates the `Selenium::WebDriver::Chrome::Options`
object it receives, and relies on those changes later when the options
are used. If `Selenium::WebDriver::Chrome::Service.driver_path` is set
but a different options object is used, Selenium will raise "cannot find
Chrome binary". Therefore, this commit ensures that the options object
passed to `Selenium::WebDriver::DriverFinder.path` is the same options
object used by the driver later.
method cause an Internal Server Error due to a TypeError.
In order to display the extraced source of a syntax error, we try
to locate the node id for the backtrace location. The call to
RubyVM::AbstractSyntaxTree.node_id_for_backtrace_location is expecting
a Thread::Backtrace::Location object, but we are passing a
SourceMapLocation instead.
This commit does two things:
1) it addresses the issue by making sure that we are always passing
a Thread::Backtrace::Location instead
2) it allows the development view to show the extracted source fragment
We can't run this test on Ruby 2.7 due to minitest being locked in the
Gemfile to an older version, so we should use that as a condition
instead of skipping if minitest doesn't have metadata.