diff options
author | Shinya Maeda <shinya@gitlab.com> | 2017-06-30 02:22:05 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2017-07-05 18:38:34 +0900 |
commit | 8a9d08af07a892d2699abcc914a81c9e46eff7be (patch) | |
tree | 2f1fb8a2022599876acf00a9a6c3c7e92b0675f8 /app | |
parent | c98c8f9a883776c4c6ffc3cf9c2214541bb8d75b (diff) | |
download | gitlab-ce-8a9d08af07a892d2699abcc914a81c9e46eff7be.tar.gz |
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 |