summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Griffith <dyl.griffith@gmail.com>2018-05-16 09:56:28 +0200
committerDylan Griffith <dyl.griffith@gmail.com>2018-05-16 11:42:09 +0200
commit1cfa5ed07065f04531900fe0931deaaaef3e69d2 (patch)
treedf0b8854e8b64d3c7b53571aebe04a69e9e4fa1f
parent983bc6b175ab47fafefe2866dd19c3fdb98c2b84 (diff)
downloadgitlab-ce-1cfa5ed07065f04531900fe0931deaaaef3e69d2.tar.gz
Refactor out duplication in runner_policy.rb46010-allow-managing-group-runners-via-api
-rw-r--r--app/policies/ci/runner_policy.rb12
1 files changed, 8 insertions, 4 deletions
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