aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/test/cases/callbacks_test.rb
blob: 9a0657ee890778a9cd827991326b11d75b138b62 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
require 'helper'
require 'jobs/callback_job'

require 'active_support/core_ext/object/inclusion'

class CallbacksTest < ActiveSupport::TestCase
  test 'perform callbacks' do
    performed_callback_job = CallbackJob.new.tap { |j| j.execute("A-JOB-ID") }
    assert "CallbackJob ran before_perform".in? performed_callback_job.history
    assert "CallbackJob ran after_perform".in? performed_callback_job.history
    assert "CallbackJob ran around_perform_start".in? performed_callback_job.history
    assert "CallbackJob ran around_perform_stop".in? performed_callback_job.history
  end

  test 'enqueue callbacks' do
    enqueued_callback_job = CallbackJob.enqueue
    assert "CallbackJob ran before_enqueue".in? enqueued_callback_job.history
    assert "CallbackJob ran after_enqueue".in? enqueued_callback_job.history
    assert "CallbackJob ran around_enqueue_start".in? enqueued_callback_job.history
    assert "CallbackJob ran around_enqueue_stop".in? enqueued_callback_job.history
  end
end