Merge pull request #2335 from tchak/do-not-notify-draft-dossier-delete
Only notify on dossier supression if dossier is en_construction
This commit is contained in:
commit
8d829dc246
3 changed files with 15 additions and 5 deletions
|
@ -291,9 +291,11 @@ class Dossier < ApplicationRecord
|
|||
deleted_dossier = DeletedDossier.create!(dossier_id: id, procedure: procedure, state: state, deleted_at: now)
|
||||
update(hidden_at: now)
|
||||
|
||||
administration_emails = followers_gestionnaires.present? ? followers_gestionnaires.pluck(:email) : [procedure.administrateur.email]
|
||||
administration_emails.each do |email|
|
||||
DossierMailer.notify_deletion_to_administration(deleted_dossier, email).deliver_later
|
||||
if en_construction?
|
||||
administration_emails = followers_gestionnaires.present? ? followers_gestionnaires.pluck(:email) : [procedure.administrateur.email]
|
||||
administration_emails.each do |email|
|
||||
DossierMailer.notify_deletion_to_administration(deleted_dossier, email).deliver_later
|
||||
end
|
||||
end
|
||||
DossierMailer.notify_deletion_to_user(deleted_dossier, user.email).deliver_later
|
||||
end
|
||||
|
|
|
@ -498,7 +498,7 @@ describe NewUser::DossiersController, type: :controller do
|
|||
end
|
||||
|
||||
context 'when dossier is owned by signed in user' do
|
||||
let(:dossier) { create(:dossier, user: user, autorisation_donnees: true) }
|
||||
let(:dossier) { create(:dossier, :en_construction, user: user, autorisation_donnees: true) }
|
||||
|
||||
it do
|
||||
expect(DossierMailer).to receive(:notify_deletion_to_administration).with(kind_of(DeletedDossier), dossier.procedure.administrateur.email).and_return(double(deliver_later: nil))
|
||||
|
|
|
@ -859,7 +859,7 @@ describe Dossier do
|
|||
end
|
||||
|
||||
context 'where gestionnaires are following the dossier' do
|
||||
let(:dossier) { create(:dossier, :followed) }
|
||||
let(:dossier) { create(:dossier, :en_construction, :followed) }
|
||||
let!(:non_following_gestionnaire) do
|
||||
non_following_gestionnaire = create(:gestionnaire)
|
||||
non_following_gestionnaire.procedures << dossier.procedure
|
||||
|
@ -873,11 +873,19 @@ describe Dossier do
|
|||
end
|
||||
|
||||
context 'when there are no following gestionnaires' do
|
||||
let(:dossier) { create(:dossier, :en_construction) }
|
||||
it 'notifies the procedure administrateur' do
|
||||
expect(DossierMailer).to have_received(:notify_deletion_to_administration).once
|
||||
expect(DossierMailer).to have_received(:notify_deletion_to_administration).with(deleted_dossier, dossier.procedure.administrateur.email)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier is brouillon' do
|
||||
let(:dossier) { create(:dossier) }
|
||||
it 'do not notifies the procedure administrateur' do
|
||||
expect(DossierMailer).not_to have_received(:notify_deletion_to_administration)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'webhook' do
|
||||
|
|
Loading…
Reference in a new issue