Skip to content

Is job creation done in the same transaction as everything else, and can be rolled back? #908

Answered by bensheldon
jjb asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, though there might be edge cases; for example, I'm not sure about the intricacies of require_new and joinable and Active Record's built-in transactions.

The simplest case should work:

expect do
  ApplicationRecord.transaction do
    TestJob.perform_later
    raise ActiveRecord::Rollback
  end
end.not_to change(GoodJob::Job, :count)

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@bensheldon
Comment options

@jjb
Comment options

Answer selected by jjb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants