summaryrefslogtreecommitdiff
path: root/spec/requests
diff options
context:
space:
mode:
authorFrancisco Javier López <fjlopez@gitlab.com>2018-04-06 15:23:49 +0000
committerDouwe Maan <douwe@gitlab.com>2018-04-06 15:23:49 +0000
commitf20912df033d07c46b0989012244d96d0a12b66d (patch)
tree6207b8face17f9b7166ba1a5e047032e3927e53e /spec/requests
parent44f4a674e2a87d104f700265d835aba000c589f0 (diff)
downloadgitlab-ce-f20912df033d07c46b0989012244d96d0a12b66d.tar.gz
Extend API for importing a project export with overwrite support
Diffstat (limited to 'spec/requests')
-rw-r--r--spec/requests/api/project_import_spec.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/requests/api/project_import_spec.rb b/spec/requests/api/project_import_spec.rb
index 5d13e6de741..f68057a92a1 100644
--- a/spec/requests/api/project_import_spec.rb
+++ b/spec/requests/api/project_import_spec.rb
@@ -114,6 +114,29 @@ describe API::ProjectImport do
expect(import_project.description).to eq('Hello world')
end
+ context 'when target path already exists in namespace' do
+ let(:existing_project) { create(:project, namespace: user.namespace) }
+
+ it 'does not schedule an import' do
+ expect_any_instance_of(Project).not_to receive(:import_schedule)
+
+ post api('/projects/import', user), path: existing_project.path, file: fixture_file_upload(file)
+
+ expect(response).to have_gitlab_http_status(400)
+ expect(json_response['message']).to eq('Name has already been taken')
+ end
+
+ context 'when param overwrite is true' do
+ it 'schedules an import' do
+ stub_import(user.namespace)
+
+ post api('/projects/import', user), path: existing_project.path, file: fixture_file_upload(file), overwrite: true
+
+ expect(response).to have_gitlab_http_status(201)
+ end
+ end
+ end
+
def stub_import(namespace)
expect_any_instance_of(Project).to receive(:import_schedule)
expect(::Projects::CreateService).to receive(:new).with(user, hash_including(namespace_id: namespace.id)).and_call_original