Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2018-08-03 14:07:50 +0300
committerJames Lopez <james@jameslopez.es>2018-08-03 14:07:50 +0300
commit107292dd3ab26489ab8fe613b9b3185aa6d66087 (patch)
tree723c6c12300077eb4a989525185d256149486d46 /spec/support/shared_examples/services/gitlab_projects_import_service_shared_examples.rb
parentb901df220c9411eba4f541ac91b3e275a0dfa1df (diff)
Fix spec warnings and template helper
Diffstat (limited to 'spec/support/shared_examples/services/gitlab_projects_import_service_shared_examples.rb')
-rw-r--r--spec/support/shared_examples/services/gitlab_projects_import_service_shared_examples.rb54
1 files changed, 54 insertions, 0 deletions
diff --git a/spec/support/shared_examples/services/gitlab_projects_import_service_shared_examples.rb b/spec/support/shared_examples/services/gitlab_projects_import_service_shared_examples.rb
new file mode 100644
index 00000000000..b8db35a6ef9
--- /dev/null
+++ b/spec/support/shared_examples/services/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