From 8a9d08af07a892d2699abcc914a81c9e46eff7be Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Fri, 30 Jun 2017 02:22:05 +0900 Subject: Fix policy by new guild line --- app/policies/ci/pipeline_schedule_policy.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'app') 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 -- cgit v1.2.1