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

34 lines
1.1 KiB
Ruby
Raw Normal View History

2016-04-02 18:10:28 +05:30
require 'spec_helper'
describe RepositoryImportWorker do
let(:project) { create(:project) }
subject { described_class.new }
describe '#perform' do
2016-06-02 11:05:42 +05:30
context 'when the import was successful' do
it 'imports a project' do
expect_any_instance_of(Projects::ImportService).to receive(:execute).
and_return({ status: :ok })
2016-04-02 18:10:28 +05:30
2016-06-02 11:05:42 +05:30
expect_any_instance_of(Repository).to receive(:expire_emptiness_caches)
expect_any_instance_of(Project).to receive(:import_finish)
2016-04-02 18:10:28 +05:30
2016-06-02 11:05:42 +05:30
subject.perform(project.id)
end
end
context 'when the import has failed' do
it 'hide the credentials that were used in the import URL' do
error = %Q{remote: Not Found fatal: repository 'https://user:pass@test.com/root/repoC.git/' not found }
expect_any_instance_of(Projects::ImportService).to receive(:execute).
and_return({ status: :error, message: error })
subject.perform(project.id)
expect(project.reload.import_error).to include("https://*****:*****@test.com/root/repoC.git/")
end
2016-04-02 18:10:28 +05:30
end
end
end