rails/activejob/test/jobs
Jean Boussier e922c59207 Implement Active Job enqueue_after_transaction_commit
A fairly common mistake with Rails is to enqueue a job from inside a
transaction, with a record as argumemnt, which then lead to a RecordNotFound
error when picked up by the queue.

This is even one of the arguments advanced for job runners backed by the
database such as `solid_queue`, `delayed_job` or `good_job`.

But relying on this is undesirable in my opinion as it makes the Active Job
abstraction leaky, and if in the future you need to migrate to another backend
or even just move the queue to a separate database, you may experience a lot of
race conditions of the sort.

To resolve this problem globally, we can make Active Job optionally transaction
aware, and automatically defer job queueing to `after_commit`.

Co-Authored-By: Cristian Bica <cristian.bica@gmail.com>
2024-04-03 16:32:16 +02:00
..
abort_before_enqueue_job.rb Don't run AJ after_enqueue / after_perform when chain is halted: 2019-12-09 17:17:23 +01:00
after_discard_retry_job.rb This method lets job authors define a block which will be run when a job is about to be discarded. 2023-05-08 14:28:42 -04:00
application_job.rb [Active Job] rubocop -a --only Layout/EmptyLineAfterMagicComment 2017-07-11 13:12:32 +09:00
arguments_round_trip_job.rb Add ActiveJob::Serializers::BigDecimalSerializer 2022-07-19 15:31:41 -04:00
callback_job.rb [Active Job] rubocop -a --only Layout/EmptyLineAfterMagicComment 2017-07-11 13:12:32 +09:00
configuration_job.rb Allow ActiveJob::Base.set to configure job when using .perform_now 2021-10-12 13:53:38 -07:00
disable_log_job.rb Add an option to disable logging for jobs with sensitive arguments 2019-11-08 13:53:23 -05:00
enqueue_error_job.rb Implement Active Job enqueue_after_transaction_commit 2024-04-03 16:32:16 +02:00
gid_job.rb [Active Job] rubocop -a --only Layout/EmptyLineAfterMagicComment 2017-07-11 13:12:32 +09:00
hello_job.rb [Active Job] rubocop -a --only Layout/EmptyLineAfterMagicComment 2017-07-11 13:12:32 +09:00
inherited_job.rb [Active Job] rubocop -a --only Layout/EmptyLineAfterMagicComment 2017-07-11 13:12:32 +09:00
kwargs_job.rb [Active Job] rubocop -a --only Layout/EmptyLineAfterMagicComment 2017-07-11 13:12:32 +09:00
logging_job.rb Fix incorrect arguments for Active Job test job 2023-07-02 16:25:09 +10:00
multiple_kwargs_job.rb Make assert_<enqueued|performed>_with() compare hashes ignoring order of keys 2018-09-21 00:09:40 +05:30
nested_job.rb [Active Job] rubocop -a --only Layout/EmptyLineAfterMagicComment 2017-07-11 13:12:32 +09:00
overridden_logging_job.rb [Active Job] rubocop -a --only Layout/EmptyLineAfterMagicComment 2017-07-11 13:12:32 +09:00
prefixed_job.rb Stop queue_name_prefix from being global 2019-09-13 18:30:19 -03:00
provider_jid_job.rb [Active Job] rubocop -a --only Layout/EmptyLineAfterMagicComment 2017-07-11 13:12:32 +09:00
queue_adapter_job.rb Delete extra empty line 2021-08-22 01:28:14 +02:00
raising_job.rb Fix AJ TestAdapter#performed_jobs not properly counting job: 2020-03-09 19:46:11 -04:00
rescue_job.rb Allow jobs to rescue all exceptions 2021-01-23 08:35:51 -05:00
retry_job.rb Set, serialize, and deserialize Active Job scheduled_at as Time; deserialize enqueued_at as Time; deprecate setting scheduled_at= with numeric/epoch 2023-09-26 17:01:41 -07:00
timezone_dependent_job.rb Require time extensions in the job that depends on time 2019-08-02 00:52:02 -04:00
translated_hello_job.rb [Active Job] rubocop -a --only Layout/EmptyLineAfterMagicComment 2017-07-11 13:12:32 +09:00