instance method
interrupt_job_after_step
Ruby on Rails 8.1.2
Since v8.1.2Signature
interrupt_job_after_step(job, step, &block)
Interrupt a job after a step.
Note that there’s no checkpoint after the final step so it won’t be interrupted.
class MyJob < ApplicationJob
include ActiveJob::Continuable
cattr_accessor :items, default: []
def perform
step :step_one { items << 1 }
step :step_two { items << 2 }
step :step_three { items << 3 }
step :step_four { items << 4 }
end
end
test "interrupt job after step" do
MyJob.perform_later
interrupt_job_after_step(MyJob, :step_two) { perform_enqueued_jobs }
assert_equal [1, 2], MyJob.items
perform_enqueued_jobs
assert_equal [1, 2, 3, 4], MyJob.items
end
Parameters
-
jobreq -
stepreq -
blockblock
Source
# File activejob/lib/active_job/continuation/test_helper.rb, line 65
def interrupt_job_after_step(job, step, &block)
require_active_job_test_adapter!("interrupt_job_after_step")
queue_adapter.with(stopping: ->() { after_step?(job, step) }, &block)
end
Defined in activejob/lib/active_job/continuation/test_helper.rb line 65
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveJob::Continuation::TestHelper