Commit Graph

918 Commits

Author SHA1 Message Date
Jean Boussier 27140247c2 Cleanup `defined?` usage
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.
2024-01-05 15:05:35 +01:00
Jean Boussier c2636a615e
Merge pull request #50491 from byroot/bump-required-ruby
Bump the required Ruby version to 3.1.0
2023-12-31 09:16:59 +01:00
Jean Boussier 6ba2fdb2fe Bump the required Ruby version to 3.1.0
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.
2023-12-31 08:54:03 +01:00
Will Jessop 7606002f13 Move singleton require.
ActiveSupport::Deprecation used to `include Singleton` which is why the require is here, but it was removed in 9812641891 (June 5 2023). Leaving the require seems to have been an oversight.

However, module ActiveJob::Serializers::ObjectSerializer does require Singleton and was relying on AS:Deprecation to require it. This PR just moves the require to the place it's actually used.
2023-12-30 12:02:01 +00:00
John Hawthorn 1a4474e7ee
Revert "Do not overwrite AJ logger if it is supplied" 2023-12-04 17:32:50 -08:00
Joshua Young 18098ccc4c [Fix #50230] Preserve serialized timezone when deserializing with `ActiveJob::Serializers::TimeWithZoneSerializer` 2023-12-03 00:37:09 +10:00
Hartley McGuire d64acfdcac
Fix Active Job skips
Similarly to Action Mailbox, these tests didn't pass because the skip
patch was included before ActiveSupport::TestCase was defined. Moving
the patch to the bottom of the file fixes the issue.

Once the skip patch was fixed, all of the skips were due to differences
in adapters which aren't really test skips as much as tests that should
not ever run against those adapters.
2023-11-30 11:11:22 -05:00
Aerdayne e03cc187f5 Do not overwrite AJ logger if it is supplied
Use conditional assignment within 'active_job.logger' initializer
2023-11-25 09:36:45 +01:00
Rafael Mendonça França 03dae98092
Remove deprecated `:exponentially_longer` value for the `:wait` in `retry_on` 2023-11-22 22:13:59 +00:00
Rafael Mendonça França 798289699d
Remove deprecated support to set numeric values to `scheduled_at` attribute 2023-11-22 22:13:06 +00:00
Rafael Mendonça França 2a761d23d2
Remove deprecated primitive serializer for `BigDecimal` arguments 2023-11-22 22:13:03 +00:00
Katherine Oelsner e57e462a62 ActiveJob: fallback serializing String subclasses
https://github.com/rails/rails/pull/50090 broke serialization of String
subclasses that don't have serializers, like ActiveSupport::SafeBuffer.

Co-authored-by: John Hawthorn <john@hawthorn.email>
2023-11-20 23:41:19 +00:00
fatkodima 14578eaa4f Fix ActiveJob arguments serialization to correctly serialize String subclasses having custom serializers
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2023-11-18 01:55:24 +02:00
Aidan Haran 6dd980fed0 Remove unused test job 2023-11-08 16:33:53 +00:00
Aashish Saini d8b3c557e9 Use cannonical form of library names 2023-10-30 12:51:35 -05:00
Jean Boussier 9497f47131 Turn skips into errors on Rails CI
We had a few cases of tests being skipped accidentally on CI
hence not bein ran for a long time.

Skipping make sense when running the test suite locally, e.g.
you may not have Redis or some other dependency running.

But on CI, a test not being ran should be considered an error.
2023-10-26 12:46:01 +02:00
William Johnston 584a9d409c
Fix ActiveJob method name in sucker_punch 1.0 error 2023-10-23 16:13:11 -05:00
Akhil G Krishnan 6eb93332c4 Typo fix in BigDecimal job arguments warning 2023-10-19 21:22:31 +05:30
Dustin Brown be9d0f05a4 Don't include enqueuing info when job wasn't enqueued 2023-10-11 10:57:36 -07:00
Jonathan Hefner 4230d0d2be Fix perform_enqueued_jobs :at option doc [ci-skip]
The `:at` option will perform jobs that have been enqueued to run at the
exact specified time, as well as before the specified time.
2023-10-07 12:26:26 -05:00
Jonathan Hefner 705d515ac5 Reword adapter caveat for perform_enqueued_jobs [ci-skip] 2023-10-07 12:26:26 -05:00
Jonathan Hefner 3f2987403e Reword queue_adapter_for_test doc [ci-skip] 2023-10-07 12:26:26 -05:00
Jonathan Hefner ed08eea99f Capitalize framework names [ci-skip] 2023-10-07 12:26:26 -05:00
Rafael Mendonça França 1f0262aa2b
Separate the CI environment from the application CI environment
Right now we are using both to test the Rails applications we generate
and to test Rails itself. Let's keep CI for the app and BUILDKITE to
the framework.
2023-10-04 09:36:51 +00:00
Bart de Water 95b6fbd00f Stop building AS::Notifications::Event manually
It's possible since Rails 6 (3ea2857943) to let the framework create Event objects, but the guides and docs weren't updated to lead with this example.

Manually instantiating an Event doesn't record CPU time and allocations, I've seen it more than once that people copy-pasting the example code get confused about these stats returning 0. The tests here show that - just like the apps I've worked on - the old pattern keeps getting copy-pasted.
2023-09-29 12:34:23 -04:00
Petrik de Heus 6c9967f85a
Merge pull request #49413 from ghiculescu/document-retry-on
Document hierarchy for `retry_on` and `discard_on`
2023-09-28 07:34:06 +02:00
Petrik de Heus a7041d3138
Merge pull request #49394 from johanstenberg92/fix-method-documentation-for-attempts-retry-on [ci skip]
Adjust method documentation for `ActiveJob::Exceptions::ClassMethods#retry_on`
2023-09-28 07:28:35 +02:00
Alex bb8d6c9349 Document hierarchy for `retry_on` and `discard_on`
Fixes https://github.com/rails/rails/issues/49406
2023-09-28 15:00:29 +10:00
Rafael Mendonça França 32eba97a08
Make sure scheduled_at is a Time object when asserting enqueued jobs
When the `:at` attribute is sent to the test adapter it is converted
to a float, and that float is what is added to the payload, so we
need to convert back to a Time object.

See:
8a37276416/activejob/lib/active_job/enqueuing.rb (L95)
8a37276416/activejob/lib/active_job/queue_adapters/test_adapter.rb (L34)
2023-09-27 15:29:11 +00:00
fatkodima 7ef86b6a49 Enable `Lint/RedundantSafeNavigation` rubocop cop 2023-09-27 14:55:07 +03:00
Johan Stenberg 9ea1e7aa78
Update activejob/lib/active_job/exceptions.rb
Co-authored-by: Alex Ghiculescu <alex@tanda.co>
2023-09-27 08:37:12 +02:00
Rafael Mendonça França fb6c6007d0
Development of Rails 7.2 starts now
🎉
2023-09-27 03:59:11 +00:00
Rafael Mendonça França e5386cb402
Preparing for 7.1.0.rc1 release 2023-09-27 03:08:31 +00:00
Ben Sheldon [he/him] c919b474a7
Set, serialize, and deserialize Active Job `scheduled_at` as Time; deserialize `enqueued_at` as Time; deprecate setting `scheduled_at=` with numeric/epoch
Co-authored-by: Adam Pahlevi <adam.pahlevi@gmail.com>
2023-09-26 17:01:41 -07:00
Johan Stenberg 09889cd4f0 Adjust method documentation for ActiveJob::Exceptions::ClassMethods#retry_on. The argument does take the initial job execution attempt into account, this is not reflected in the method documentation. 2023-09-26 20:07:18 +02:00
Victor Mours 1bdabc1102 Clarify that the default retry strategy uses polynomial backoff and not exponential backoff 2023-09-16 00:51:14 +02:00
Shouichi Kamiya 7ff936570b Add tests for AJ events
Because events are documented but not tested.
2023-09-14 16:05:26 +09:00
Shouichi Kamiya 51ac8b9f6f Enable Minitest/LiteralAsActualArgument
There are assertions that expected/actual arguments are passed in the
reversed order by mistake. Enabling the LiteralAsActualArgument rule
prevents this mistake from happening.

The existing tests were auto-corrected by rubocop with a bit of
indentation adjustment.

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2023-09-13 10:09:32 +09:00
Rafael Mendonça França 699dfdb426
Preparing for 7.1.0.beta1 release 2023-09-13 00:36:01 +00:00
Akhil G Krishnan 61a9c1a92a Ruby code block indentation issue fix
[skip ci] indentation fix

[skip ci] review changes added

[skip ci] indentation fix
2023-09-07 01:14:48 +05:30
Ben Sheldon b1b7debaa3
Fix Active Job log message to correctly report a job failed to enqueue when the adapter raises an `ActiveJob::EnqueueError` 2023-09-02 07:52:43 -07:00
Adrianna Chang 27c5c7cd99
Merge pull request #48920 from fidalgo/fidalgo/update-assert_enqueued_with-documentation
[docs] Update assert_enqueued_with documentation with keyword arguments example
2023-08-29 10:36:22 -04:00
Rafael Mendonça França 53a3a95d01
Merge PR #48010 2023-08-21 17:39:03 +00:00
Hartley McGuire ff6e885d59
Remove uneeded requires of core_ext/string/filters
`actionpack/lib/action_dispatch/routing.rb`
- added: 013745151b
- removed: 93034ad7fe

`activejob/lib/active_job/log_subscriber.rb`
- added: b314ab555e
- removed: 5ab2034730

`activemodel/lib/active_model/errors.rb`
- added: cf7fac7e29
- removed: 9de6457ab0

`activerecord/lib/active_record/core.rb`
- added: b3bfa361c5
- removed: e1066f450d

`activesupport/lib/active_support/core_ext/module/introspection.rb`
- added: 358ac36edf
- removed: 167b4153ca

`activesupport/lib/active_support/duration.rb`
- added: 75924c4517
- removed: a91ea1d510

`railties/lib/rails/commands/server/server_command.rb`
- added: f217364893
- removed: 553b86fc75

`railties/lib/rails/command/base.rb`
- added: 6813edc7d9
- removed: b617a561d8
2023-08-16 17:39:25 -04:00
Jonathan del Strother 074d431493
Fix invalid durations in ActiveJob serialization
Durations that were round-tripped through ActiveJob::Arguments.serialize
would appear fine at a first glance, but trying to perform
duration-math on them would fail:

```
irb(main):001:0> d = ActiveJob::Arguments.deserialize(ActiveJob::Arguments.serialize([1.year]))[0]
=> 1 year
irb(main):002:0> d + 1.day
activesupport-6.1.4.4/lib/active_support/duration.rb:242:in `+': undefined method `merge' for [[:years, 1]]:Array (NoMethodError)
```
2023-08-13 11:27:16 +01:00
Paulo Fidalgo 9dbac2cedc
Update assert_enqueued_with documentation with keyword arguments example
This commit adds an example to the `assert_enqueued_with` method documentation,
demonstrating how to use it with keyword arguments.
The example clarifies that keyword arguments should be specified as a hash inside an array,
providing guidance for developers writing tests for jobs that use keyword arguments.
2023-08-11 09:54:59 +02:00
Yasuo Honda d867313fbc
Merge pull request #48626 from ghiculescu/active-job-async-test
Active Job: `async` adapter should always run jobs immediately if `immediate` set
2023-07-03 09:37:56 +09:00
Alex Ghiculescu 639dab59dc Active Job: `async` adapter should always run jobs immediately if `immediate` set
This is an internal fix, not user facing. I noticed it while working on https://github.com/rails/rails/pull/48585.

The `async` adapter has an `immediate` option, which should only be used in tests. This option should tell the adapter to run jobs inline. This works correctly with `perform_later`, but it does not work with `enqueue_at`, which is what other internal mechanisms such as `retry_job` use.

This PR fixes this bug.
2023-07-03 09:02:51 +10:00
Alex Ghiculescu 2385b6e4e5 Fix incorrect arguments for Active Job test job
This is an internal fix, not user facing.

Currently the `LoggingJob` does not accept more than one argument. But there's [a few tests](f46d3452ae/activejob/test/cases/test_helper_test.rb (L518-L537)) that call it with multiple arguments and assert that it is queued correctly. Those tests pass because the job is not performed, but if the job was performed, they'd fail.

This PR just fixes `LoggingJob` to accept a splat of arguments, and adds a test to ensure that it works correctly.
2023-07-02 16:25:09 +10:00
Alex Ghiculescu ba70a5be86 Make `perform_enqueued_jobs` compatible with all Active Job adapters 2023-06-28 20:08:08 +10:00