Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2017-06-29 20:22:05 +0300
committerShinya Maeda <shinya@gitlab.com>2017-07-05 12:38:34 +0300
commit8a9d08af07a892d2699abcc914a81c9e46eff7be (patch)
tree2f1fb8a2022599876acf00a9a6c3c7e92b0675f8 /app/policies
parentc98c8f9a883776c4c6ffc3cf9c2214541bb8d75b (diff)
Fix policy by new guild line
Diffstat (limited to 'app/policies')
-rw-r--r--app/policies/ci/pipeline_schedule_policy.rb18
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