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

39 lines
1.1 KiB
Ruby
Raw Normal View History

2020-11-24 15:15:51 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe PagesTransferWorker do
describe '#perform' do
2021-03-11 19:13:27 +05:30
Gitlab::PagesTransfer::METHODS.each do |meth|
2020-11-24 15:15:51 +05:30
context "when method is #{meth}" do
let(:args) { [1, 2, 3] }
it 'calls the service with the given arguments' do
expect_next_instance_of(Gitlab::PagesTransfer) do |service|
expect(service).to receive(meth).with(*args).and_return(true)
end
subject.perform(meth, args)
end
it 'raises an error when the service returns false' do
expect_next_instance_of(Gitlab::PagesTransfer) do |service|
expect(service).to receive(meth).with(*args).and_return(false)
end
expect { subject.perform(meth, args) }
.to raise_error(described_class::TransferFailedError)
end
end
end
describe 'when method is not allowed' do
it 'does nothing' do
expect(Gitlab::PagesTransfer).not_to receive(:new)
subject.perform('object_id', [])
end
end
end
end