2019-03-30 07:15:48 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-02-06 13:25:46 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 15:08:50 +00:00
|
|
|
RSpec.describe PagesDomainVerificationCronWorker do
|
2018-02-06 13:25:46 +00:00
|
|
|
subject(:worker) { described_class.new }
|
|
|
|
|
2020-02-11 18:08:58 +00:00
|
|
|
describe '#perform', :sidekiq do
|
2019-04-30 12:05:54 +00:00
|
|
|
let!(:verified) { create(:pages_domain) }
|
2020-02-11 18:08:58 +00:00
|
|
|
let!(:reverify) { create(:pages_domain, :reverify, :with_project) }
|
2019-04-30 12:05:54 +00:00
|
|
|
let!(:disabled) { create(:pages_domain, :disabled) }
|
2018-02-06 13:25:46 +00:00
|
|
|
|
2019-06-04 04:44:02 +00:00
|
|
|
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-04-30 12:05:54 +00:00
|
|
|
it 'enqueues a PagesDomainVerificationWorker for domains needing verification' do
|
2018-02-06 13:25:46 +00:00
|
|
|
[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-02-11 18:08:58 +00:00
|
|
|
|
|
|
|
it_behaves_like 'a pages cronjob scheduling jobs with context', PagesDomainVerificationWorker do
|
|
|
|
let(:extra_domain) { create(:pages_domain, :reverify, :with_project) }
|
|
|
|
end
|
2018-02-06 13:25:46 +00:00
|
|
|
end
|
|
|
|
end
|