diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-07-07 13:09:35 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-07-07 13:11:48 +0300 |
commit | f108153cef0d538a06c07a17f7a0429aa8333e84 (patch) | |
tree | c690a8c847b33a053496c72d21b6c0a01274bd6e /app/policies/ci | |
parent | 1ee9f7db83fb0e33b9cffbf437d20db343afd8a3 (diff) |
Remove update|admin_pipeline_schedule from Project, and grant it in PipelineSchedule
Diffstat (limited to 'app/policies/ci')
-rw-r--r-- | app/policies/ci/pipeline_schedule_policy.rb | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/app/policies/ci/pipeline_schedule_policy.rb b/app/policies/ci/pipeline_schedule_policy.rb index db561dafbd3..6b7598e1821 100644 --- a/app/policies/ci/pipeline_schedule_policy.rb +++ b/app/policies/ci/pipeline_schedule_policy.rb @@ -2,24 +2,13 @@ module Ci class PipelineSchedulePolicy < PipelinePolicy alias_method :pipeline_schedule, :subject - condition(:protected_action) do - owned_by_developer? && owned_by_another? + condition(:owner_of_schedule) do + can?(:developer_access) && pipeline_schedule.owned_by?(@user) end - rule { protected_action }.prevent :update_pipeline_schedule - - private - - def owned_by_developer? - return false unless @user - - pipeline_schedule.project.team.developer?(@user) - end - - def owned_by_another? - return false unless @user - - !pipeline_schedule.owned_by?(@user) + rule { can?(:master_access) | owner_of_schedule }.policy do + enable :update_pipeline_schedule + enable :admin_pipeline_schedule end end end |