2018-01-04 05:42:52 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Projects::GitlabProjectsImportService do
|
2018-01-31 16:51:05 +00:00
|
|
|
set(:namespace) { create(:namespace) }
|
2018-03-29 11:57:21 +00:00
|
|
|
let(:path) { 'test-path' }
|
2018-01-04 05:42:52 +00:00
|
|
|
let(:file) { fixture_file_upload(Rails.root + 'spec/fixtures/doc_sample.txt', 'text/plain') }
|
2018-03-29 11:57:21 +00:00
|
|
|
let(:import_params) { { namespace_id: namespace.id, path: path, file: file } }
|
|
|
|
subject { described_class.new(namespace.owner, import_params) }
|
2018-01-04 05:42:52 +00:00
|
|
|
|
|
|
|
describe '#execute' do
|
|
|
|
context 'with an invalid path' do
|
|
|
|
let(:path) { '/invalid-path/' }
|
|
|
|
|
|
|
|
it 'returns an invalid project' do
|
|
|
|
project = subject.execute
|
|
|
|
|
|
|
|
expect(project).not_to be_persisted
|
|
|
|
expect(project).not_to be_valid
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a valid path' do
|
|
|
|
it 'creates a project' do
|
|
|
|
project = subject.execute
|
|
|
|
|
|
|
|
expect(project).to be_persisted
|
|
|
|
expect(project).to be_valid
|
|
|
|
end
|
|
|
|
end
|
2018-03-29 11:57:21 +00:00
|
|
|
|
|
|
|
context 'override params' do
|
|
|
|
it 'stores them as import data when passed' do
|
|
|
|
project = described_class
|
|
|
|
.new(namespace.owner, import_params, description: 'Hello')
|
|
|
|
.execute
|
|
|
|
|
|
|
|
expect(project.import_data.data['override_params']['description']).to eq('Hello')
|
|
|
|
end
|
|
|
|
end
|
2018-01-04 05:42:52 +00:00
|
|
|
end
|
|
|
|
end
|