diff --git a/spec/controllers/instructeurs/dossiers_controller_spec.rb b/spec/controllers/instructeurs/dossiers_controller_spec.rb index b5cd1e38c..e8a2a838e 100644 --- a/spec/controllers/instructeurs/dossiers_controller_spec.rb +++ b/spec/controllers/instructeurs/dossiers_controller_spec.rb @@ -457,6 +457,20 @@ describe Instructeurs::DossiersController, type: :controller do expect(flash.notice).to be_present end end + + context "when the dossier is deleted by user" do + let(:dossier) { create(:dossier, :accepte, procedure: procedure) } + + before do + dossier.update!(hidden_by_user_at: 1.hour.ago) + subject + end + + it "does not create a commentaire" do + expect { subject }.to change(Commentaire, :count).by(0) + expect(flash.alert).to be_present + end + end end describe "#create_avis" do