Fix ProcedureAdministrateursController#destroy
- The "no remove oneself" rule wasn't actually enforced - `flash.error` is not a flash category
This commit is contained in:
parent
fb75a55b89
commit
062f52feb9
2 changed files with 15 additions and 3 deletions
|
@ -32,7 +32,8 @@ module Administrateurs
|
||||||
|
|
||||||
# Prevent self-removal (Also enforced in the UI)
|
# Prevent self-removal (Also enforced in the UI)
|
||||||
if administrateur == current_administrateur
|
if administrateur == current_administrateur
|
||||||
flash.error = "Vous ne pouvez pas vous retirer vous-même d’une démarche."
|
flash.alert = "Vous ne pouvez pas vous retirer vous-même d’une démarche."
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
# Actually remove the admin
|
# Actually remove the admin
|
||||||
|
|
|
@ -18,8 +18,19 @@ describe Administrateurs::ProcedureAdministrateursController, type: :controller
|
||||||
it 'removes the admin from the procedure' do
|
it 'removes the admin from the procedure' do
|
||||||
subject
|
subject
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
expect(signed_in_admin.procedures.reload).to include(procedure)
|
expect(flash[:notice]).to be_present
|
||||||
expect(other_admin.procedures.reload).not_to include(procedure)
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue