summaryrefslogtreecommitdiff
path: root/app/policies/ci/pipeline_policy.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/policies/ci/pipeline_policy.rb')
-rw-r--r--app/policies/ci/pipeline_policy.rb19
1 files changed, 18 insertions, 1 deletions
diff --git a/app/policies/ci/pipeline_policy.rb b/app/policies/ci/pipeline_policy.rb
index 10aa2d3e72a..e71cc358353 100644
--- a/app/policies/ci/pipeline_policy.rb
+++ b/app/policies/ci/pipeline_policy.rb
@@ -1,7 +1,24 @@
module Ci
class PipelinePolicy < BasePolicy
+ alias_method :pipeline, :subject
+
def rules
- delegate! @subject.project
+ delegate! pipeline.project
+
+ if can?(:update_pipeline) && !can_user_update?
+ cannot! :update_pipeline
+ end
+ end
+
+ private
+
+ def can_user_update?
+ user_access.can_push_or_merge_to_branch?(pipeline.ref)
+ end
+
+ def user_access
+ @user_access ||= ::Gitlab::UserAccess
+ .new(user, project: pipeline.project)
end
end
end