diff options
author | Dylan Griffith <dyl.griffith@gmail.com> | 2018-05-16 10:56:28 +0300 |
---|---|---|
committer | Dylan Griffith <dyl.griffith@gmail.com> | 2018-05-16 12:42:09 +0300 |
commit | 1cfa5ed07065f04531900fe0931deaaaef3e69d2 (patch) | |
tree | df0b8854e8b64d3c7b53571aebe04a69e9e4fa1f /app/policies/ci | |
parent | 983bc6b175ab47fafefe2866dd19c3fdb98c2b84 (diff) |
Refactor out duplication in runner_policy.rb
Diffstat (limited to 'app/policies/ci')
-rw-r--r-- | app/policies/ci/runner_policy.rb | 12 |
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 |