diff --git a/app/controllers/webhook_controller.rb b/app/controllers/webhook_controller.rb index 7129b4e1264..6af7bbecb03 100644 --- a/app/controllers/webhook_controller.rb +++ b/app/controllers/webhook_controller.rb @@ -41,6 +41,14 @@ def helpscout if instructeur url = manager_instructeur_url(instructeur) html << link_to_manager(instructeur, url) + + instructeur.assign_to.each do |assign_to| + if !assign_to.instant_email_dossier_notifications_enabled || + !assign_to.instant_email_message_notifications_enabled || + !assign_to.instant_expert_avis_email_notifications_enabled + html << "Notifs désactivées Procedure##{assign_to.groupe_instructeur.procedure_id}" + end + end end if administrateur diff --git a/spec/controllers/webhook_controller_spec.rb b/spec/controllers/webhook_controller_spec.rb index 9c81f95873d..97f8cd7735e 100644 --- a/spec/controllers/webhook_controller_spec.rb +++ b/spec/controllers/webhook_controller_spec.rb @@ -65,6 +65,20 @@ expect(payload['html']).to have_selector("a[href='#{manager_administrateur_url(admin)}']") end end + + context "when notifications are disabled" do + let(:instructeur) { create(:instructeur, user:) } + let(:procedure) { create(:procedure) } + before do + create(:assign_to, instructeur:, procedure:, + instant_email_dossier_notifications_enabled: false + ) + end + + it 'returns a summary of disabled notifications' do + expect(payload['html']).to have_text("Notifs désactivées Procedure##{procedure.id}") + end + end end end