diff options
author | James Lopez <james@jameslopez.es> | 2018-02-13 10:54:04 +0100 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2018-02-13 15:25:49 +0100 |
commit | 79879145e5cfb3837b3a2f77fb7c35bd1234068c (patch) | |
tree | bb89912038271fc2ccddacbf31b3ded3be3b5ed8 /lib/api | |
parent | 4a0d56daacc3f1825c5f9644a0ea63842fa9da7d (diff) | |
download | gitlab-ce-79879145e5cfb3837b3a2f77fb7c35bd1234068c.tar.gz |
add more specs
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/project_import.rb | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/api/project_import.rb b/lib/api/project_import.rb index d554d6d12bd..1e51c92cbf1 100644 --- a/lib/api/project_import.rb +++ b/lib/api/project_import.rb @@ -17,7 +17,6 @@ module API end resource :projects, requirements: { id: %r{[^/]+} } do - params do requires :path, type: String, desc: 'The new project path and 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.' @@ -30,11 +29,10 @@ module API render_api_error!('The file is invalid', 400) unless file_is_valid? namespace = import_params[:namespace] - - namespace = if namespace && namespace =~ /^\d+$/ - Namespace.find_by(id: namespace) - elsif namespace.blank? + namespace = if namespace.blank? current_user.namespace + elsif namespace =~ /^\d+$/ + Namespace.find_by(id: namespace) else Namespace.find_by_path_or_name(namespace) end @@ -43,7 +41,7 @@ module API file: import_params[:file]['tempfile']) project = ::Projects::GitlabProjectsImportService.new(current_user, project_params).execute - render_api_error!(project&.full_messages&.first, 400) unless project&.saved? + render_api_error!(project.errors.full_messages&.first, 400) unless project.saved? present project, with: Entities::ProjectImportStatus end |