diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-17 18:07:07 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-17 18:07:07 +0000 |
commit | 8746f6e79d7717a8cb16737fecdb977feaa22cdb (patch) | |
tree | cd1080192931a17e459fc5b476f3c5d91f83dde3 /app/services/environments | |
parent | 30785cadee10a5deaa45ada13def96bcfa6663b0 (diff) | |
download | gitlab-ce-8746f6e79d7717a8cb16737fecdb977feaa22cdb.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/environments')
-rw-r--r-- | app/services/environments/update_service.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/app/services/environments/update_service.rb b/app/services/environments/update_service.rb new file mode 100644 index 00000000000..e02b2398426 --- /dev/null +++ b/app/services/environments/update_service.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module Environments + class UpdateService < BaseService + def execute(environment) + unless can?(current_user, :update_environment, environment) + return ServiceResponse.error( + message: _('Unauthorized to update the environment'), + payload: { environment: environment } + ) + end + + if environment.update(**params) + ServiceResponse.success(payload: { environment: environment }) + else + ServiceResponse.error( + message: environment.errors.full_messages, + payload: { environment: environment } + ) + end + end + end +end |