zh nich catches 2

This commit is contained in:
Shinya Maeda 2017-06-28 21:42:13 +09:00
parent ad30a5a9bb
commit 5c91e10b9e
2 changed files with 7 additions and 3 deletions

View File

@ -1,9 +1,9 @@
class Projects::PipelineSchedulesController < Projects::ApplicationController
before_action :schedule, only: [:edit, :update, :destroy, :take_ownership]
before_action :schedule, except: [:index, :new, :create]
before_action :authorize_read_pipeline_schedule!
before_action :authorize_create_pipeline_schedule!, only: [:new, :create]
before_action :authorize_update_pipeline_schedule!, only: [:edit, :take_ownership, :update]
before_action :authorize_update_pipeline_schedule!, except: [:index, :new, :create]
before_action :authorize_admin_pipeline_schedule!, only: [:destroy]
def index

View File

@ -5,7 +5,7 @@ module Ci
def rules
super
if owned_by_developer? && pipeline_schedule.owner != user
if owned_by_developer? && owned_by_another?
cannot! :update_pipeline_schedule
end
end
@ -15,5 +15,9 @@ module Ci
def owned_by_developer?
pipeline_schedule.project.team.developer?(user)
end
def owned_by_another?
!pipeline_schedule.owned_by?(user)
end
end
end