2015-12-31 18:33:35 -05:00
|
|
|
# frozen_string_literal: true
|
2015-07-14 00:55:24 -04:00
|
|
|
require_relative 'helper'
|
2019-02-28 15:43:50 -05:00
|
|
|
require 'active_job'
|
2015-07-14 00:55:24 -04:00
|
|
|
|
2019-02-28 15:43:50 -05:00
|
|
|
describe 'ActiveJob' do
|
|
|
|
it 'does not allow Sidekiq::Worker in AJ::Base classes' do
|
|
|
|
ex = assert_raises ArgumentError do
|
2019-07-20 20:17:15 -04:00
|
|
|
Class.new(ActiveJob::Base) do
|
|
|
|
include Sidekiq::Worker
|
|
|
|
end
|
|
|
|
end
|
|
|
|
assert_includes ex.message, "can only include Sidekiq::Worker::Options"
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'allows Sidekiq::Options in AJ::Base classes' do
|
|
|
|
Class.new(ActiveJob::Base) do
|
|
|
|
include Sidekiq::Worker::Options
|
|
|
|
sidekiq_options retry: true
|
|
|
|
sidekiq_retry_in { |count, _exception| count * 10 }
|
|
|
|
sidekiq_retries_exhausted do |msg, _exception|
|
|
|
|
Sidekiq.logger.warn "Failed #{msg['class']} with #{msg['args']}: #{msg['error_message']}"
|
|
|
|
end
|
2019-02-28 15:43:50 -05:00
|
|
|
end
|
2015-07-14 00:55:24 -04:00
|
|
|
end
|
|
|
|
end
|