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
project.errors.add(:new_namespace, error_message)
false
end 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 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