From fb75a55b89e07c1addfb7c2a1b644e646d4aa46e Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 5 Jan 2022 16:19:26 +0100 Subject: [PATCH] Add specs for Administrateurs::ProcedureAdministrateursController --- ...ocedure_administrateurs_controller_spec.rb | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 spec/controllers/administrateurs/procedure_administrateurs_controller_spec.rb diff --git a/spec/controllers/administrateurs/procedure_administrateurs_controller_spec.rb b/spec/controllers/administrateurs/procedure_administrateurs_controller_spec.rb new file mode 100644 index 000000000..bbec91374 --- /dev/null +++ b/spec/controllers/administrateurs/procedure_administrateurs_controller_spec.rb @@ -0,0 +1,26 @@ +describe Administrateurs::ProcedureAdministrateursController, type: :controller do + let(:signed_in_admin) { create(:administrateur) } + let(:other_admin) { create(:administrateur) } + let(:procedure) { create(:procedure, administrateurs: [signed_in_admin, other_admin]) } + + before do + sign_in(signed_in_admin.user) + end + + describe '#destroy' do + subject do + delete :destroy, params: { procedure_id: procedure.id, id: admin_to_remove.id }, format: :js, xhr: true + end + + context 'when removing another admin' do + let(:admin_to_remove) { other_admin } + + 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) + end + end + end +end