Commit ad802385 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Refactored transfer_service #execute action

parent acd573f1
...@@ -12,17 +12,13 @@ module Projects ...@@ -12,17 +12,13 @@ module Projects
TransferError = Class.new(StandardError) TransferError = Class.new(StandardError)
def execute(new_namespace) def execute(new_namespace)
if !new_namespace.blank? && allowed_transfer?(current_user, project, new_namespace) if new_namespace.blank?
transfer(project, new_namespace) raise TransferError, 'Please select a new namespace for your project.'
else
error_message = if new_namespace.blank?
'Please select a new namespace for your project.'
else
'Transfer failed, please contact an admin.'
end end
project.errors.add(:new_namespace, error_message) unless allowed_transfer?(current_user, project, new_namespace)
false raise TransferError, 'Transfer failed, please contact an admin.'
end end
transfer(project, new_namespace)
rescue Projects::TransferService::TransferError => ex rescue Projects::TransferService::TransferError => ex
project.reload project.reload
project.errors.add(:new_namespace, ex.message) project.errors.add(:new_namespace, ex.message)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment