diff options
author | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-05-22 16:04:21 -0500 |
---|---|---|
committer | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-05-22 16:09:40 -0500 |
commit | ad80238507fd5e1efb205c9f72efcbe909821be5 (patch) | |
tree | ce2309e36546c2ae80a9b134ec7ff61135c07cb5 /app | |
parent | acd573f1e612f446d6994b891cf65d189950faff (diff) | |
download | gitlab-ce-ad80238507fd5e1efb205c9f72efcbe909821be5.tar.gz |
Refactored transfer_service #execute actionprevent-project-transfer
Diffstat (limited to 'app')
-rw-r--r-- | app/services/projects/transfer_service.rb | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/app/services/projects/transfer_service.rb b/app/services/projects/transfer_service.rb index 74fc83b4e77..1c24b27a870 100644 --- a/app/services/projects/transfer_service.rb +++ b/app/services/projects/transfer_service.rb @@ -12,17 +12,13 @@ module Projects TransferError = Class.new(StandardError) def execute(new_namespace) - if !new_namespace.blank? && allowed_transfer?(current_user, project, new_namespace) - transfer(project, new_namespace) - else - error_message = if new_namespace.blank? - 'Please select a new namespace for your project.' - else - 'Transfer failed, please contact an admin.' - end - project.errors.add(:new_namespace, error_message) - false + if new_namespace.blank? + raise TransferError, 'Please select a new namespace for your project.' end + unless allowed_transfer?(current_user, project, new_namespace) + raise TransferError, 'Transfer failed, please contact an admin.' + end + transfer(project, new_namespace) rescue Projects::TransferService::TransferError => ex project.reload project.errors.add(:new_namespace, ex.message) |