gitlab-org--gitlab-foss/app/policies/ci/pipeline_schedule_policy.rb

29 lines
823 B
Ruby
Raw Normal View History

# frozen_string_literal: true
module Ci
class PipelineSchedulePolicy < PipelinePolicy
2017-06-26 05:25:08 -04:00
alias_method :pipeline_schedule, :subject
condition(:protected_ref) do
2017-12-08 02:49:55 -05:00
ref_protected?(@user, @subject.project, @subject.project.repository.tag_exists?(@subject.ref), @subject.ref)
end
condition(:owner_of_schedule) do
pipeline_schedule.owned_by?(@user)
2017-06-28 08:42:13 -04:00
end
2017-06-27 03:16:15 -04:00
rule { can?(:create_pipeline) }.enable :play_pipeline_schedule
rule { can?(:admin_pipeline) | (can?(:update_build) & owner_of_schedule) }.policy do
enable :update_pipeline_schedule
enable :admin_pipeline_schedule
2017-06-28 08:42:13 -04:00
end
rule { can?(:admin_pipeline_schedule) & ~owner_of_schedule }.policy do
enable :take_ownership_pipeline_schedule
end
rule { protected_ref }.prevent :play_pipeline_schedule
end
end