diff options
author | Shinya Maeda <shinya@gitlab.com> | 2017-06-29 20:22:05 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2017-07-05 12:36:19 +0300 |
commit | c023bbbb50149c8896d7791e7c267c21f2bf9d6d (patch) | |
tree | 689e872fd93f1f7a45a76b7c2fc1a848d24ec2d1 /app | |
parent | 7d5351e15e605687ad5dfb2fc09b8f3fa7080bcc (diff) |
Fix policy by new guild line
Diffstat (limited to 'app')
-rw-r--r-- | app/policies/ci/pipeline_schedule_policy.rb | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/app/policies/ci/pipeline_schedule_policy.rb b/app/policies/ci/pipeline_schedule_policy.rb index 0e26b6e688a..db561dafbd3 100644 --- a/app/policies/ci/pipeline_schedule_policy.rb +++ b/app/policies/ci/pipeline_schedule_policy.rb @@ -2,22 +2,24 @@ module Ci class PipelineSchedulePolicy < PipelinePolicy alias_method :pipeline_schedule, :subject - def rules - super - - if owned_by_developer? && owned_by_another? - cannot! :update_pipeline_schedule - end + condition(:protected_action) do + owned_by_developer? && owned_by_another? end + rule { protected_action }.prevent :update_pipeline_schedule + private def owned_by_developer? - pipeline_schedule.project.team.developer?(user) + return false unless @user + + pipeline_schedule.project.team.developer?(@user) end def owned_by_another? - !pipeline_schedule.owned_by?(user) + return false unless @user + + !pipeline_schedule.owned_by?(@user) end end end |