debian-mirror-gitlab/spec/workers/pages_domain_verification_cron_worker_spec.rb

35 lines
1.1 KiB
Ruby
Raw Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe PagesDomainVerificationCronWorker do
2018-03-17 18:26:18 +05:30
subject(:worker) { described_class.new }
2020-03-13 15:44:24 +05:30
describe '#perform', :sidekiq do
2019-07-31 22:56:46 +05:30
let!(:verified) { create(:pages_domain) }
2020-03-13 15:44:24 +05:30
let!(:reverify) { create(:pages_domain, :reverify, :with_project) }
2019-07-31 22:56:46 +05:30
let!(:disabled) { create(:pages_domain, :disabled) }
2018-03-17 18:26:18 +05:30
2019-09-04 21:01:54 +05:30
it 'does nothing if the database is read-only' do
allow(Gitlab::Database).to receive(:read_only?).and_return(true)
expect(PagesDomainVerificationWorker).not_to receive(:perform_async).with(reverify.id)
worker.perform
end
2019-07-31 22:56:46 +05:30
it 'enqueues a PagesDomainVerificationWorker for domains needing verification' do
2018-03-17 18:26:18 +05:30
[reverify, disabled].each do |domain|
expect(PagesDomainVerificationWorker).to receive(:perform_async).with(domain.id)
end
expect(PagesDomainVerificationWorker).not_to receive(:perform_async).with(verified.id)
worker.perform
end
2020-03-13 15:44:24 +05:30
it_behaves_like 'a pages cronjob scheduling jobs with context', PagesDomainVerificationWorker do
let(:extra_domain) { create(:pages_domain, :reverify, :with_project) }
end
2018-03-17 18:26:18 +05:30
end
end