From a9915cff87bc078563896a1c7291f80360171933 Mon Sep 17 00:00:00 2001 From: Neuville Romain Date: Tue, 8 Oct 2024 12:42:43 +0200 Subject: [PATCH] ux(mattermost_notif): better motif category has changed alert on mattermost (#2383) * ux(mattermost_notif): better motif category has changed alert on mattermost * add id rdvsp --- app/jobs/alert_motif_category_has_changed_job.rb | 10 +++++----- spec/jobs/alert_motif_category_has_changed_job_spec.rb | 8 ++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/jobs/alert_motif_category_has_changed_job.rb b/app/jobs/alert_motif_category_has_changed_job.rb index 532a45d99..8a3061522 100644 --- a/app/jobs/alert_motif_category_has_changed_job.rb +++ b/app/jobs/alert_motif_category_has_changed_job.rb @@ -13,14 +13,14 @@ def perform(motif_id) private def alert_message - @alert_message ||= " - ⚠️ Le motif #{motif.name} (#{motif.id}) vient de changer - de catégory malgré la présence de #{motif.rdvs.count} associés. - " + @alert_message ||= + "⚠️ Le motif #{motif.name} (ID rdv-sp: #{motif.rdv_solidarites_motif_id}) de l'organisation" \ + " #{motif.organisation.name} (ID rdv-sp: #{motif.organisation.rdv_solidarites_organisation_id})" \ + " vient de changer de catégorie malgré la présence de #{motif.rdvs.count} rendez-vous associés." end def alert_on_mattermost - MattermostClient.send_to_notif_channel(alert_message) + MattermostClient.send_to_private_channel(alert_message) end def alert_on_sentry diff --git a/spec/jobs/alert_motif_category_has_changed_job_spec.rb b/spec/jobs/alert_motif_category_has_changed_job_spec.rb index 2698cb0ba..9f91915fa 100644 --- a/spec/jobs/alert_motif_category_has_changed_job_spec.rb +++ b/spec/jobs/alert_motif_category_has_changed_job_spec.rb @@ -9,7 +9,11 @@ let!(:rdv) { create(:rdv, motif: motif) } it "sends a message to Mattermost and Sentry" do - expect(MattermostClient).to receive(:send_to_notif_channel) + expect(MattermostClient).to receive(:send_to_private_channel).with( + "⚠️ Le motif #{motif.name} (ID rdv-sp: #{motif.rdv_solidarites_motif_id}) de l'organisation" \ + " #{motif.organisation.name} (ID rdv-sp: #{motif.organisation.rdv_solidarites_organisation_id}) vient de" \ + " changer de catégorie malgré la présence de #{motif.rdvs.count} rendez-vous associés." + ) expect(Sentry).to receive(:capture_message) subject @@ -18,7 +22,7 @@ context "when motif has no rdvs" do it "does not send a message to Mattermost and Sentry" do - expect(MattermostClient).not_to receive(:send_to_notif_channel) + expect(MattermostClient).not_to receive(:send_to_private_channel) expect(Sentry).not_to receive(:capture_message) subject