debian-mirror-gitlab/app/policies/ci/pipeline_policy.rb

18 lines
399 B
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
module Ci
class PipelinePolicy < BasePolicy
2017-09-10 17:25:29 +05:30
delegate { @subject.project }
condition(:protected_ref) do
access = ::Gitlab::UserAccess.new(@user, project: @subject.project)
if @subject.tag?
!access.can_create_tag?(@subject.ref)
else
!access.can_update_branch?(@subject.ref)
end
2017-08-17 22:00:37 +05:30
end
2017-09-10 17:25:29 +05:30
rule { protected_ref }.prevent :update_pipeline
2017-08-17 22:00:37 +05:30
end
end