bug(instructeurs/groupes_instructeurs#*): any ACL here ?
This commit is contained in:
parent
641a33e1e0
commit
b6c2742cda
2 changed files with 20 additions and 0 deletions
|
@ -3,6 +3,8 @@ module Instructeurs
|
|||
include UninterlacePngConcern
|
||||
include GroupeInstructeursSignatureConcern
|
||||
|
||||
before_action :ensure_allowed!
|
||||
|
||||
ITEMS_PER_PAGE = 25
|
||||
|
||||
def index
|
||||
|
@ -98,5 +100,12 @@ module Instructeurs
|
|||
def instructeur_id
|
||||
params[:instructeur][:id]
|
||||
end
|
||||
|
||||
def ensure_allowed!
|
||||
if !(current_administrateur&.owns?(procedure) || procedure.instructeurs_self_management_enabled?)
|
||||
flash[:alert] = "Vous n’avez pas le droit de gérer les instructeurs de cette démarche"
|
||||
redirect_to instructeur_procedure_path(procedure)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,6 +14,17 @@ describe Instructeurs::GroupeInstructeursController, type: :controller do
|
|||
sign_in(instructeur.user)
|
||||
end
|
||||
|
||||
describe "before_action: ensure_allowed!" do
|
||||
it "is present" do
|
||||
before_actions = Instructeurs::GroupeInstructeursController
|
||||
._process_action_callbacks
|
||||
.filter { |process_action_callbacks| process_action_callbacks.kind == :before }
|
||||
.map(&:filter)
|
||||
|
||||
expect(before_actions).to include(:ensure_allowed!)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#index' do
|
||||
context 'of a procedure I own' do
|
||||
before do
|
||||
|
|
Loading…
Reference in a new issue