2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
RSpec.shared_examples 'gitlab projects import validations' do
|
2018-11-18 11:00:15 +05:30
|
|
|
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
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
context 'when there is a project with the same path' do
|
|
|
|
let(:existing_project) { create(:project, namespace: namespace) }
|
|
|
|
let(:path) { existing_project.path}
|
|
|
|
|
|
|
|
it 'does not create the project' do
|
|
|
|
project = subject.execute
|
|
|
|
|
|
|
|
expect(project).to be_invalid
|
|
|
|
expect(project).not_to be_persisted
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when overwrite param is set' do
|
|
|
|
let(:overwrite) { true }
|
|
|
|
|
|
|
|
it 'creates a project in a temporary full_path' do
|
|
|
|
project = subject.execute
|
|
|
|
|
|
|
|
expect(project).to be_valid
|
|
|
|
expect(project).to be_persisted
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|