diff options
author | Francisco Javier López <fjlopez@gitlab.com> | 2018-07-21 02:25:10 +0300 |
---|---|---|
committer | Francisco Javier López <fjlopez@gitlab.com> | 2018-07-21 02:25:10 +0300 |
commit | 38eab74483e728018a129c36d4064313f5d152f6 (patch) | |
tree | f946438bc3085b175fe20e08ebf0773cfbfdb782 /spec/support | |
parent | 334ee10727540c8e16d47075781564fd21e8a9cb (diff) |
EE Port
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/shared_examples/gitlab_projects_import_service_shared_examples.rb | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/spec/support/shared_examples/gitlab_projects_import_service_shared_examples.rb b/spec/support/shared_examples/gitlab_projects_import_service_shared_examples.rb new file mode 100644 index 00000000000..b8db35a6ef9 --- /dev/null +++ b/spec/support/shared_examples/gitlab_projects_import_service_shared_examples.rb @@ -0,0 +1,54 @@ +shared_examples 'gitlab projects import validations' 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 + + 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 |