From 1cfa5ed07065f04531900fe0931deaaaef3e69d2 Mon Sep 17 00:00:00 2001 From: Dylan Griffith Date: Wed, 16 May 2018 09:56:28 +0200 Subject: Refactor out duplication in runner_policy.rb --- app/policies/ci/runner_policy.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'app/policies') diff --git a/app/policies/ci/runner_policy.rb b/app/policies/ci/runner_policy.rb index 4649dc645ba..895abe87d86 100644 --- a/app/policies/ci/runner_policy.rb +++ b/app/policies/ci/runner_policy.rb @@ -6,10 +6,14 @@ module Ci condition(:owned_runner) { @user.ci_owned_runners.exists?(@subject.id) } rule { anonymous }.prevent_all - rule { admin | owned_runner }.enable :assign_runner - rule { admin | owned_runner }.enable :read_runner - rule { admin | owned_runner }.enable :update_runner - rule { admin | owned_runner }.enable :delete_runner + + rule { admin | owned_runner }.policy do + enable :assign_runner + enable :read_runner + enable :update_runner + enable :delete_runner + end + rule { ~admin & locked }.prevent :assign_runner end end -- cgit v1.2.1