diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-06-05 16:56:29 +0300 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-06-06 16:00:28 +0300 |
commit | e6568d806d85b74c75fc37f1afc7c01c139818ba (patch) | |
tree | 38f638596bc27df2dc5c59817d91f410d72ca09a /app/services/projects | |
parent | 96747556e70470caed4175730f9342af2f0f593d (diff) |
Don't update/create projects errors were added
This could be done when a block is passed in EE.
Diffstat (limited to 'app/services/projects')
-rw-r--r-- | app/services/projects/create_service.rb | 3 | ||||
-rw-r--r-- | app/services/projects/update_service.rb | 15 |
2 files changed, 14 insertions, 4 deletions
diff --git a/app/services/projects/create_service.rb b/app/services/projects/create_service.rb index d4a5b979f63..a02a9052fb2 100644 --- a/app/services/projects/create_service.rb +++ b/app/services/projects/create_service.rb @@ -46,6 +46,9 @@ module Projects yield(@project) if block_given? + # If the block added errors, don't try to save the project + return @project if @project.errors.any? + @project.creator = current_user if forked_from_project_id diff --git a/app/services/projects/update_service.rb b/app/services/projects/update_service.rb index 0d1e2e758cd..d8250cd8102 100644 --- a/app/services/projects/update_service.rb +++ b/app/services/projects/update_service.rb @@ -19,6 +19,9 @@ module Projects yield if block_given? + # If the block added errors, don't try to save the project + return validation_failed! if project.errors.any? + if project.update_attributes(params.except(:default_branch)) if project.previous_changes.include?('path') project.rename_repo @@ -30,10 +33,7 @@ module Projects success else - model_errors = project.errors.full_messages.to_sentence - error_message = model_errors.presence || 'Project could not be updated!' - - error(error_message) + validation_failed! end end @@ -45,6 +45,13 @@ module Projects private + def validation_failed! + model_errors = project.errors.full_messages.to_sentence + error_message = model_errors.presence || 'Project could not be updated!' + + error(error_message) + end + def renaming_project_with_container_registry_tags? new_path = params[:path] |