rails/activejob/lib
Jacopo 20545fc820 Allow testing discard_on/retry_on ActiveJob::DeserializationError
Previously in `perform_enqueued_jobs`, `deserialize_arguments_if_needed`
was called before calling `perform_now`. When a record no longer exists
and is serialized using GlobalID this led to raising
an `ActiveJob::DeserializationError` before reaching `perform_now` call.
This behaviour makes difficult testing the job `discard_on/retry_on` logic.

Now `deserialize_arguments_if_needed` call is postponed to when `perform_now`
is called.

Example:

```ruby
class UpdateUserJob < ActiveJob::Base
  discard_on ActiveJob::DeserializationError

  def perform(user)
    # ...
  end
end

User.destroy_all
assert_nothing_raised do
  perform_enqueued_jobs only: UpdateUserJob
end
assert_no_enqueued_jobs
```

Before this changes the test will fail, now it passes.
2021-08-23 21:16:56 +02:00
..
active_job Allow testing discard_on/retry_on ActiveJob::DeserializationError 2021-08-23 21:16:56 +02:00
rails/generators/job Strip duplicated suffixes more strictly 2018-04-22 14:30:07 +09:00
active_job.rb Avoid using class_eval and just include a module 2021-08-17 22:16:06 +00:00