2018-07-24 06:00:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-03-07 08:02:56 -05:00
|
|
|
module Ci
|
|
|
|
class TriggerPolicy < BasePolicy
|
2017-04-06 17:06:42 -04:00
|
|
|
delegate { @subject.project }
|
|
|
|
|
|
|
|
with_options scope: :subject, score: 0
|
2019-06-25 07:41:11 -04:00
|
|
|
condition(:legacy) { @subject.supports_legacy_tokens? && @subject.legacy? }
|
2017-04-06 17:06:42 -04:00
|
|
|
|
|
|
|
with_score 0
|
|
|
|
condition(:is_owner) { @user && @subject.owner_id == @user.id }
|
|
|
|
|
|
|
|
rule { ~can?(:admin_build) }.prevent :admin_trigger
|
|
|
|
rule { legacy | is_owner }.enable :admin_trigger
|
|
|
|
|
|
|
|
rule { can?(:admin_build) }.enable :manage_trigger
|
2017-03-07 08:02:56 -05:00
|
|
|
end
|
|
|
|
end
|