2019-07-07 11:18:12 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-03 12:29:30 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe CronjobQueue do
|
|
|
|
let(:worker) do
|
|
|
|
Class.new do
|
2018-03-17 18:26:18 +05:30
|
|
|
def self.name
|
|
|
|
'DummyWorker'
|
|
|
|
end
|
|
|
|
|
|
|
|
include ApplicationWorker
|
2020-03-09 13:42:32 +05:30
|
|
|
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
|
2016-11-03 12:29:30 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'sets the queue name of a worker' do
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(worker.sidekiq_options['queue'].to_s).to eq('cronjob:dummy')
|
2016-11-03 12:29:30 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'disables retrying of failed jobs' do
|
|
|
|
expect(worker.sidekiq_options['retry']).to eq(false)
|
|
|
|
end
|
2020-03-09 13:42:32 +05:30
|
|
|
|
|
|
|
it 'automatically clears project, user and namespace from the context', :aggregate_failues do
|
|
|
|
worker_context = worker.get_worker_context.to_lazy_hash.transform_values(&:call)
|
|
|
|
|
|
|
|
expect(worker_context[:user]).to be_nil
|
|
|
|
expect(worker_context[:root_namespace]).to be_nil
|
|
|
|
expect(worker_context[:project]).to be_nil
|
|
|
|
end
|
2016-11-03 12:29:30 +05:30
|
|
|
end
|