diff options
-rw-r--r-- | lib/api/project_import.rb | 7 | ||||
-rw-r--r-- | spec/requests/api/project_import_spec.rb | 5 |
2 files changed, 7 insertions, 5 deletions
diff --git a/lib/api/project_import.rb b/lib/api/project_import.rb index 4bbb78a62f9..396c316af22 100644 --- a/lib/api/project_import.rb +++ b/lib/api/project_import.rb @@ -17,6 +17,7 @@ module API end params do + requires :name, type: String, desc: 'The new project name' optional :namespace, type: String, desc: 'The ID or name of the namespace that the project will be imported into. Defaults to the user namespace.' requires :file, type: File, desc: 'The project export file to be imported' end @@ -37,9 +38,11 @@ module API Namespace.find_by_path_or_name(namespace) end - project = ::Projects::GitlabProjectsImportService.new(current_user, import_params).execute + project_params = import_params.merge(namespace: namespace.id) - render_api_error!(link.project.full_messages.first, 400) unless project.saved? + project = ::Projects::GitlabProjectsImportService.new(current_user, project_params).execute + + render_api_error!(project.full_messages.first, 400) unless project.saved? present project, with: Entities::ProjectImportStatus end diff --git a/spec/requests/api/project_import_spec.rb b/spec/requests/api/project_import_spec.rb index 55df2d34419..b810c81108c 100644 --- a/spec/requests/api/project_import_spec.rb +++ b/spec/requests/api/project_import_spec.rb @@ -16,11 +16,10 @@ describe API::ProjectImport do end describe 'POST /projects/import' do - it 'schedules an import' do expect_any_instance_of(Project).to receive(:import_schedule) - post api('/projects/import', user), file: file, namespace: namespace.full_path + post api('/projects/import', user), name: 'test', file: file, namespace: namespace.full_path expect(project.status).to eq('started') end @@ -43,7 +42,7 @@ describe API::ProjectImport do expect(response).to have_gitlab_http_status(200) expect(json_response).to include('import_status' => 'failed', - 'import_error' => 'error') + 'import_error' => 'error') end end end |