2017-07-09 13:49:52 -04:00
|
|
|
# frozen_string_literal: true
|
2017-07-10 09:40:03 -04:00
|
|
|
|
2016-08-06 12:41:18 -04:00
|
|
|
require "helper"
|
|
|
|
require "jobs/callback_job"
|
2014-05-22 13:33:23 -04:00
|
|
|
|
2016-08-06 12:41:18 -04:00
|
|
|
require "active_support/core_ext/object/inclusion"
|
2014-05-22 13:33:23 -04:00
|
|
|
|
|
|
|
class CallbacksTest < ActiveSupport::TestCase
|
2016-08-06 12:41:18 -04:00
|
|
|
test "perform callbacks" do
|
2014-08-25 10:34:50 -04:00
|
|
|
performed_callback_job = CallbackJob.new("A-JOB-ID")
|
|
|
|
performed_callback_job.perform_now
|
2014-05-22 13:33:23 -04:00
|
|
|
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
|
|
|
|
|
2016-08-06 12:41:18 -04:00
|
|
|
test "enqueue callbacks" do
|
2014-08-25 10:34:50 -04:00
|
|
|
enqueued_callback_job = CallbackJob.perform_later
|
2014-05-22 13:33:23 -04:00
|
|
|
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
|