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

17 lines
536 B
Ruby
Raw Normal View History

2016-09-29 09:46:39 +05:30
module Ci
class RunnerPolicy < BasePolicy
2017-09-10 17:25:29 +05:30
with_options scope: :subject, score: 0
condition(:shared) { @subject.is_shared? }
2016-09-29 09:46:39 +05:30
2017-09-10 17:25:29 +05:30
with_options scope: :subject, score: 0
condition(:locked, scope: :subject) { @subject.locked? }
2016-09-29 09:46:39 +05:30
2017-09-10 17:25:29 +05:30
condition(:authorized_runner) { @user.ci_authorized_runners.include?(@subject) }
2016-09-29 09:46:39 +05:30
2017-09-10 17:25:29 +05:30
rule { anonymous }.prevent_all
rule { admin | authorized_runner }.enable :assign_runner
rule { ~admin & shared }.prevent :assign_runner
rule { ~admin & locked }.prevent :assign_runner
2016-09-29 09:46:39 +05:30
end
end