aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/test/jobs/callback_job.rb
blob: 436cb554929a81f227de12620c41419e826f78c4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

class CallbackJob < ActiveJob::Base
  before_perform ->(job) { job.history << "CallbackJob ran before_perform" }
  after_perform ->(job) { job.history << "CallbackJob ran after_perform" }

  before_enqueue ->(job) { job.history << "CallbackJob ran before_enqueue" }
  after_enqueue ->(job) { job.history << "CallbackJob ran after_enqueue" }

  around_perform do |job, block|
    job.history << "CallbackJob ran around_perform_start"
    block.call
    job.history << "CallbackJob ran around_perform_stop"
  end

  around_enqueue do |job, block|
    job.history << "CallbackJob ran around_enqueue_start"
    block.call
    job.history << "CallbackJob ran around_enqueue_stop"
  end

  def perform(person = "david")
    # NOTHING!
  end

  def history
    @history ||= []
  end
end