2019-07-07 11:18:12 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe PagesDomainVerificationWorker do
|
|
|
|
subject(:worker) { described_class.new }
|
|
|
|
|
|
|
|
let(:domain) { create(:pages_domain) }
|
|
|
|
|
|
|
|
describe '#perform' do
|
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(PagesDomain).not_to receive(:find_by).with(id: domain.id)
|
|
|
|
|
|
|
|
worker.perform(domain.id)
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
it 'does nothing for a non-existent domain' do
|
|
|
|
domain.destroy
|
|
|
|
|
|
|
|
expect(VerifyPagesDomainService).not_to receive(:new)
|
|
|
|
|
|
|
|
expect { worker.perform(domain.id) }.not_to raise_error
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'delegates to VerifyPagesDomainService' do
|
|
|
|
service = double(:service)
|
|
|
|
expected_domain = satisfy { |obj| obj == domain }
|
|
|
|
|
|
|
|
expect(VerifyPagesDomainService).to receive(:new).with(expected_domain) { service }
|
|
|
|
expect(service).to receive(:execute)
|
|
|
|
|
|
|
|
worker.perform(domain.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|