diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-04-12 12:26:18 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-04-12 12:26:18 +0300 |
commit | b09465f38d66d7ff6074843177bcdb7d72caf07f (patch) | |
tree | 40ccff4e2c64cd5f180c4dfff66f38e1536b5056 /app/policies/ci | |
parent | 7bcca2284b09e18438e6163c6ead72e10fdd2f57 (diff) |
Implement new rule for manual actions in policies
Diffstat (limited to 'app/policies/ci')
-rw-r--r-- | app/policies/ci/build_policy.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/app/policies/ci/build_policy.rb b/app/policies/ci/build_policy.rb index 8b25332b73c..0522cbdb331 100644 --- a/app/policies/ci/build_policy.rb +++ b/app/policies/ci/build_policy.rb @@ -8,6 +8,20 @@ module Ci %w[read create update admin].each do |rule| cannot! :"#{rule}_commit_status" unless can? :"#{rule}_build" end + + can! :play_build if can_play_action? + end + + private + + alias_method :build, :subject + + def can_play_action? + return false unless build.playable? + + ::Gitlab::UserAccess + .new(user, project: build.project) + .can_push_to_branch?(build.ref) end end end |