Fix ProcedureAdministrateursController#destroy

- The "no remove oneself" rule wasn't actually enforced
- `flash.error` is not a flash category
This commit is contained in:
Pierre de La Morinerie 2022-01-05 15:21:59 +00:00
parent fb75a55b89
commit 062f52feb9
2 changed files with 15 additions and 3 deletions

View file

@ -32,7 +32,8 @@ module Administrateurs
# Prevent self-removal (Also enforced in the UI)
if administrateur == current_administrateur
flash.error = "Vous ne pouvez pas vous retirer vous-même dune démarche."
flash.alert = "Vous ne pouvez pas vous retirer vous-même dune démarche."
return
end
# Actually remove the admin

View file

@ -18,8 +18,19 @@ describe Administrateurs::ProcedureAdministrateursController, type: :controller
it 'removes the admin from the procedure' do
subject
expect(response.status).to eq(200)
expect(signed_in_admin.procedures.reload).to include(procedure)
expect(other_admin.procedures.reload).not_to include(procedure)
expect(flash[:notice]).to be_present
expect(admin_to_remove.procedures.reload).not_to include(procedure)
end
end
context 'when removing oneself from a procedure' do
let(:admin_to_remove) { signed_in_admin }
it 'denies the right for an admin to remove itself' do
subject
expect(response.status).to eq(200)
expect(flash[:alert]).to be_present
expect(admin_to_remove.procedures.reload).to include(procedure)
end
end
end