From d5f360c85fa0b7980d2d5a29716c77421e56cdb3 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 15 Jul 2019 10:01:16 +0200 Subject: [PATCH] manager: fix the deletion email not being sent When deleting a dossier from the manager, the deletion notification email was not being sent. This is because the returned object from `Dossier#hide!` was invalid. --- app/controllers/manager/dossiers_controller.rb | 3 +-- app/models/dossier.rb | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/manager/dossiers_controller.rb b/app/controllers/manager/dossiers_controller.rb index 74170f17f..31867443f 100644 --- a/app/controllers/manager/dossiers_controller.rb +++ b/app/controllers/manager/dossiers_controller.rb @@ -22,9 +22,8 @@ module Manager def hide dossier = Dossier.find(params[:id]) - deleted_dossier = dossier.hide!(current_administration) + dossier.hide!(current_administration) - DossierMailer.notify_deletion_to_user(deleted_dossier, dossier.user.email).deliver_later logger.info("Le dossier #{dossier.id} est supprimé par #{current_administration.email}") flash[:notice] = "Le dossier #{dossier.id} est supprimé" diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 28f4dbee4..81c426824 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -412,7 +412,8 @@ class Dossier < ApplicationRecord def hide!(administration) update(hidden_at: Time.zone.now) - DeletedDossier.create_from_dossier(self) + deleted_dossier = DeletedDossier.create_from_dossier(self) + DossierMailer.notify_deletion_to_user(deleted_dossier, user.email).deliver_later log_dossier_operation(administration, :supprimer, self) end