2024-04-29 00:17:15 +02:00
|
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2018-07-16 14:39:04 +02:00
|
|
|
|
RSpec.describe DossierMailer, type: :mailer do
|
2019-08-06 11:02:54 +02:00
|
|
|
|
let(:to_email) { 'instructeur@exemple.gouv.fr' }
|
2018-07-16 14:39:04 +02:00
|
|
|
|
|
2019-07-22 15:49:11 +02:00
|
|
|
|
shared_examples 'a dossier notification' do
|
2019-09-10 13:29:06 +02:00
|
|
|
|
it 'is sent from a no-reply address' do
|
|
|
|
|
expect(subject.from.first).to eq(Mail::Address.new(NO_REPLY_EMAIL).address)
|
|
|
|
|
end
|
|
|
|
|
|
2019-07-22 15:49:11 +02:00
|
|
|
|
it 'includes the contact informations in the footer' do
|
|
|
|
|
expect(subject.body).to include('ne pas répondre')
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2018-11-20 11:50:25 +01:00
|
|
|
|
describe '.notify_new_draft' do
|
2024-03-27 09:16:40 +01:00
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
let(:dossier) { create(:dossier, procedure: create(:simple_procedure, :with_auto_archive), user:) }
|
2018-11-20 11:50:25 +01:00
|
|
|
|
|
2022-12-21 17:18:19 +01:00
|
|
|
|
subject { described_class.with(dossier:).notify_new_draft }
|
2018-11-20 11:50:25 +01:00
|
|
|
|
|
2024-03-26 17:23:42 +01:00
|
|
|
|
it 'includes the correct subject and body content' do
|
|
|
|
|
expect(subject.subject).to include("brouillon")
|
|
|
|
|
expect(subject.subject).to include(dossier.procedure.libelle)
|
|
|
|
|
expect(subject.body).to include(dossier.procedure.libelle)
|
|
|
|
|
expect(subject.body).to include(dossier_url(dossier, host: ENV.fetch("APP_HOST_LEGACY")))
|
|
|
|
|
expect(subject.body).to include("Vous pouvez déposer votre dossier jusqu’au")
|
|
|
|
|
expect(subject.body).to include("heure de")
|
|
|
|
|
end
|
2019-07-22 15:49:11 +02:00
|
|
|
|
|
|
|
|
|
it_behaves_like 'a dossier notification'
|
2024-03-27 09:16:40 +01:00
|
|
|
|
|
2024-03-26 17:23:42 +01:00
|
|
|
|
context "when user prefers new domain" do
|
2024-03-27 09:16:40 +01:00
|
|
|
|
let(:user) { create(:user, preferred_domain: :demarches_gouv_fr) }
|
|
|
|
|
|
2024-03-26 17:23:42 +01:00
|
|
|
|
it 'includes the correct body content and sender email' do
|
2024-04-18 18:16:22 +02:00
|
|
|
|
expect(subject.body).to include(dossier_url(dossier, host: 'demarches.gouv.fr'))
|
2024-03-27 09:16:40 +01:00
|
|
|
|
expect(header_value("From", subject)).to include("ne-pas-repondre@demarches.gouv.fr")
|
|
|
|
|
end
|
|
|
|
|
end
|
2018-11-20 11:50:25 +01:00
|
|
|
|
end
|
|
|
|
|
|
2021-07-22 14:33:39 +02:00
|
|
|
|
describe '.notify_new_answer with dossier brouillon' do
|
2022-02-16 18:26:45 +01:00
|
|
|
|
let(:service) { build(:service) }
|
|
|
|
|
let(:procedure) { create(:simple_procedure, service: service) }
|
|
|
|
|
let(:dossier) { create(:dossier, procedure: procedure) }
|
2021-11-16 15:12:05 +01:00
|
|
|
|
let(:commentaire) { create(:commentaire, dossier: dossier) }
|
|
|
|
|
subject { described_class.with(commentaire: commentaire).notify_new_answer }
|
2018-11-20 11:50:25 +01:00
|
|
|
|
|
2024-03-26 17:23:42 +01:00
|
|
|
|
it 'checks email subject and body for correct inclusions and exclusions' do
|
|
|
|
|
expect(subject.subject).to include("Nouveau message")
|
|
|
|
|
expect(subject.subject).to include(dossier.id.to_s)
|
|
|
|
|
expect(subject.body).to include(dossier.procedure.service.email)
|
|
|
|
|
expect(subject.body).not_to include(messagerie_dossier_url(dossier, host: ENV.fetch("APP_HOST_LEGACY")))
|
|
|
|
|
end
|
2021-07-22 14:33:39 +02:00
|
|
|
|
|
|
|
|
|
it_behaves_like 'a dossier notification'
|
2022-02-16 18:26:45 +01:00
|
|
|
|
|
|
|
|
|
context 'when there is no associated service' do
|
|
|
|
|
let(:service) { nil }
|
|
|
|
|
it { expect { subject }.not_to raise_error }
|
|
|
|
|
end
|
2021-07-22 14:33:39 +02:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe '.notify_new_answer with dossier en construction' do
|
2021-11-19 13:48:52 +01:00
|
|
|
|
let(:dossier) { create(:dossier, :en_construction, procedure: create(:simple_procedure)) }
|
2021-11-16 15:12:05 +01:00
|
|
|
|
let(:commentaire) { create(:commentaire, dossier: dossier) }
|
2021-11-19 13:48:52 +01:00
|
|
|
|
|
2021-11-16 15:12:05 +01:00
|
|
|
|
subject { described_class.with(commentaire: commentaire).notify_new_answer }
|
2021-07-22 14:33:39 +02:00
|
|
|
|
|
2024-03-26 17:23:42 +01:00
|
|
|
|
it 'checks email subject and body for correct inclusions' do
|
|
|
|
|
expect(subject.subject).to include("Nouveau message")
|
|
|
|
|
expect(subject.subject).to include(dossier.id.to_s)
|
|
|
|
|
expect(subject.body).to include(messagerie_dossier_url(dossier, host: ENV.fetch("APP_HOST_LEGACY")))
|
|
|
|
|
end
|
2019-07-22 15:49:11 +02:00
|
|
|
|
|
|
|
|
|
it_behaves_like 'a dossier notification'
|
2018-11-20 11:50:25 +01:00
|
|
|
|
end
|
|
|
|
|
|
2021-11-16 15:12:05 +01:00
|
|
|
|
describe '.notify_new_answer with commentaire discarded' do
|
2021-11-19 13:48:52 +01:00
|
|
|
|
let(:dossier) { create(:dossier, procedure: create(:simple_procedure)) }
|
2021-11-16 15:12:05 +01:00
|
|
|
|
let(:commentaire) { create(:commentaire, dossier: dossier, discarded_at: 2.minutes.ago) }
|
|
|
|
|
|
|
|
|
|
subject { described_class.with(commentaire: commentaire).notify_new_answer }
|
|
|
|
|
|
|
|
|
|
it { expect(subject.perform_deliveries).to be_falsy }
|
|
|
|
|
end
|
|
|
|
|
|
2024-06-04 17:52:01 +02:00
|
|
|
|
def notify_deletion_to_administration(hidden_dossier, to_email)
|
|
|
|
|
@subject = default_i18n_subject(dossier_id: hidden_dossier.id)
|
|
|
|
|
@hidden_dossier = hidden_dossier
|
2018-07-16 14:39:04 +02:00
|
|
|
|
|
2022-01-19 14:43:30 +01:00
|
|
|
|
mail(to: to_email, subject: @subject)
|
2018-07-16 14:39:04 +02:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe '.notify_deletion_to_administration' do
|
2024-06-04 17:52:01 +02:00
|
|
|
|
let(:hidden_dossier) { build(:dossier) }
|
2018-07-16 14:39:04 +02:00
|
|
|
|
|
2024-06-04 17:52:01 +02:00
|
|
|
|
subject { described_class.notify_deletion_to_administration(hidden_dossier, to_email) }
|
2018-07-16 14:39:04 +02:00
|
|
|
|
|
2024-03-26 17:23:42 +01:00
|
|
|
|
it 'verifies subject and body content for deletion notification' do
|
2024-06-04 17:52:01 +02:00
|
|
|
|
expect(subject.subject).to eq("Le dossier nº #{hidden_dossier.id} a été supprimé à la demande de l’usager")
|
2024-03-26 17:23:42 +01:00
|
|
|
|
expect(subject.body).to include("À la demande de l’usager")
|
2024-06-04 17:52:01 +02:00
|
|
|
|
expect(subject.body).to include(hidden_dossier.id)
|
|
|
|
|
expect(subject.body).to include(hidden_dossier.procedure.libelle)
|
2024-03-26 17:23:42 +01:00
|
|
|
|
end
|
2018-07-16 14:39:04 +02:00
|
|
|
|
end
|
|
|
|
|
|
2019-12-03 15:51:16 +01:00
|
|
|
|
describe '.notify_brouillon_near_deletion' do
|
|
|
|
|
let(:dossier) { create(:dossier) }
|
|
|
|
|
|
2020-03-19 09:49:25 +01:00
|
|
|
|
subject { described_class.notify_brouillon_near_deletion([dossier], dossier.user.email) }
|
2019-12-03 15:51:16 +01:00
|
|
|
|
|
2024-03-26 17:23:42 +01:00
|
|
|
|
it 'checks email body for correct inclusions regarding brouillon nearing deletion' do
|
|
|
|
|
expect(subject.body).to include("n° #{dossier.id} ")
|
|
|
|
|
expect(subject.body).to include(dossier.procedure.libelle)
|
|
|
|
|
end
|
2019-12-03 15:51:16 +01:00
|
|
|
|
end
|
2019-11-28 18:03:23 +01:00
|
|
|
|
|
|
|
|
|
describe '.notify_brouillon_deletion' do
|
|
|
|
|
let(:dossier) { create(:dossier) }
|
|
|
|
|
|
2020-03-19 09:49:25 +01:00
|
|
|
|
subject { described_class.notify_brouillon_deletion([dossier.hash_for_deletion_mail], dossier.user.email) }
|
2019-11-28 18:03:23 +01:00
|
|
|
|
|
2024-03-26 17:23:42 +01:00
|
|
|
|
it 'verifies subject and body content for brouillon deletion notification' do
|
2024-06-17 16:33:19 +02:00
|
|
|
|
expect(subject.subject).to eq("Un dossier en brouillon a été supprimé")
|
2024-03-26 17:23:42 +01:00
|
|
|
|
expect(subject.body).to include("n° #{dossier.id} (#{dossier.procedure.libelle})")
|
|
|
|
|
end
|
2019-11-28 18:03:23 +01:00
|
|
|
|
end
|
2020-02-18 17:15:32 +01:00
|
|
|
|
|
|
|
|
|
describe '.notify_automatic_deletion_to_user' do
|
2020-04-01 17:08:50 +02:00
|
|
|
|
describe 'en_construction' do
|
2024-08-22 11:14:55 +02:00
|
|
|
|
let(:hidden_dossier) { create(:dossier, :en_construction, hidden_by_expired_at: Time.zone.now, hidden_by_reason: 'expired') }
|
2020-02-18 17:15:32 +01:00
|
|
|
|
|
2024-06-04 17:52:01 +02:00
|
|
|
|
subject { described_class.notify_automatic_deletion_to_user([hidden_dossier], hidden_dossier.user.email) }
|
2020-02-18 17:15:32 +01:00
|
|
|
|
|
2024-03-26 17:23:42 +01:00
|
|
|
|
it 'checks email subject, to, and body for correct inclusions and exclusions for en_construction status' do
|
2024-06-04 17:52:01 +02:00
|
|
|
|
expect(subject.to).to eq([hidden_dossier.user.email])
|
2024-06-17 16:33:19 +02:00
|
|
|
|
expect(subject.subject).to eq("Un dossier a été supprimé de votre compte")
|
2024-06-04 17:52:01 +02:00
|
|
|
|
expect(subject.body).to include("N° #{hidden_dossier.id} ")
|
|
|
|
|
expect(subject.body).to include(hidden_dossier.procedure.libelle)
|
2024-03-26 17:23:42 +01:00
|
|
|
|
end
|
2020-04-01 17:08:50 +02:00
|
|
|
|
end
|
2020-04-02 15:05:16 +02:00
|
|
|
|
|
|
|
|
|
describe 'termine' do
|
2024-08-22 11:14:55 +02:00
|
|
|
|
let(:hidden_dossier) { create(:dossier, :accepte, hidden_by_expired_at: Time.zone.now, hidden_by_reason: 'expired') }
|
2020-04-02 15:05:16 +02:00
|
|
|
|
|
2024-06-04 17:52:01 +02:00
|
|
|
|
subject { described_class.notify_automatic_deletion_to_user([hidden_dossier], hidden_dossier.user.email) }
|
2020-04-02 15:05:16 +02:00
|
|
|
|
|
2024-03-26 17:23:42 +01:00
|
|
|
|
it 'checks email subject, to, and body for correct inclusions and exclusions for termine status' do
|
2024-06-04 17:52:01 +02:00
|
|
|
|
expect(subject.to).to eq([hidden_dossier.user.email])
|
2024-06-17 16:33:19 +02:00
|
|
|
|
expect(subject.subject).to eq("Un dossier a été supprimé de votre compte")
|
2024-06-04 17:52:01 +02:00
|
|
|
|
expect(subject.body).to include("N° #{hidden_dossier.id} ")
|
|
|
|
|
expect(subject.body).to include(hidden_dossier.procedure.libelle)
|
2024-03-26 17:23:42 +01:00
|
|
|
|
end
|
2020-04-02 15:05:16 +02:00
|
|
|
|
end
|
2020-02-18 17:15:32 +01:00
|
|
|
|
end
|
2020-02-18 17:18:06 +01:00
|
|
|
|
|
|
|
|
|
describe '.notify_automatic_deletion_to_administration' do
|
2024-08-22 11:14:55 +02:00
|
|
|
|
let(:hidden_dossier) { create(:dossier, :accepte, hidden_by_expired_at: Time.zone.now, hidden_by_reason: 'expired') }
|
2020-02-18 17:18:06 +01:00
|
|
|
|
|
2024-06-04 17:52:01 +02:00
|
|
|
|
subject { described_class.notify_automatic_deletion_to_administration([hidden_dossier], hidden_dossier.user.email) }
|
2020-02-18 17:18:06 +01:00
|
|
|
|
|
2024-03-26 17:23:42 +01:00
|
|
|
|
it 'verifies subject and body content for automatic deletion notification' do
|
2024-06-17 16:33:19 +02:00
|
|
|
|
expect(subject.subject).to eq("Un dossier a été supprimé")
|
2024-06-04 17:52:01 +02:00
|
|
|
|
expect(subject.body).to include("n° #{hidden_dossier.id} (#{hidden_dossier.procedure.libelle})")
|
2024-03-26 17:23:42 +01:00
|
|
|
|
end
|
2020-02-18 17:18:06 +01:00
|
|
|
|
end
|
2020-02-18 17:18:14 +01:00
|
|
|
|
|
2020-04-01 17:08:50 +02:00
|
|
|
|
describe '.notify_near_deletion_to_administration' do
|
|
|
|
|
describe 'en_construction' do
|
|
|
|
|
let(:dossier) { create(:dossier, :en_construction) }
|
2020-02-18 17:18:14 +01:00
|
|
|
|
|
2020-04-01 17:08:50 +02:00
|
|
|
|
subject { described_class.notify_near_deletion_to_administration([dossier], dossier.user.email) }
|
2020-02-18 17:18:14 +01:00
|
|
|
|
|
2024-03-26 17:23:42 +01:00
|
|
|
|
it 'checks email subject and body for correct inclusions for en_construction status' do
|
2024-06-17 16:33:19 +02:00
|
|
|
|
expect(subject.subject).to eq("Un dossier en attente d'instruction va bientôt être supprimé")
|
2024-03-26 17:23:42 +01:00
|
|
|
|
expect(subject.body).to include("N° #{dossier.id} ")
|
|
|
|
|
expect(subject.body).to include(dossier.procedure.libelle)
|
|
|
|
|
expect(subject.body).to include("PDF")
|
2024-06-17 16:33:19 +02:00
|
|
|
|
expect(subject.body).to include("il vous reste 14 jours pour démarrer l'instruction ")
|
2024-03-26 17:23:42 +01:00
|
|
|
|
end
|
2020-04-01 17:08:50 +02:00
|
|
|
|
end
|
2020-04-02 15:05:16 +02:00
|
|
|
|
|
|
|
|
|
describe 'termine' do
|
|
|
|
|
let(:dossier) { create(:dossier, :accepte) }
|
|
|
|
|
|
|
|
|
|
subject { described_class.notify_near_deletion_to_administration([dossier], dossier.user.email) }
|
|
|
|
|
|
2024-03-26 17:23:42 +01:00
|
|
|
|
it 'verifies subject and body content for near deletion notification of completed cases' do
|
2024-06-17 16:33:19 +02:00
|
|
|
|
expect(subject.subject).to eq("Un dossier traité va bientôt être supprimé")
|
2024-03-26 17:23:42 +01:00
|
|
|
|
expect(subject.body).to include("N° #{dossier.id} ")
|
|
|
|
|
expect(subject.body).to include(dossier.procedure.libelle)
|
|
|
|
|
end
|
2020-04-02 15:05:16 +02:00
|
|
|
|
end
|
2020-02-18 17:18:14 +01:00
|
|
|
|
end
|
|
|
|
|
|
2020-04-01 17:08:50 +02:00
|
|
|
|
describe '.notify_near_deletion_to_user' do
|
|
|
|
|
describe 'en_construction' do
|
|
|
|
|
let(:dossier) { create(:dossier, :en_construction) }
|
2020-02-18 17:18:14 +01:00
|
|
|
|
|
2020-04-01 17:08:50 +02:00
|
|
|
|
subject { described_class.notify_near_deletion_to_user([dossier], dossier.user.email) }
|
2020-02-18 17:18:14 +01:00
|
|
|
|
|
2024-03-26 17:23:42 +01:00
|
|
|
|
it 'verifies email subject, to, and body for correct inclusions for en_construction status' do
|
|
|
|
|
expect(subject.to).to eq([dossier.user.email])
|
2024-06-17 16:33:19 +02:00
|
|
|
|
expect(subject.subject).to eq("Un dossier en attente d'instruction va bientôt être supprimé")
|
2024-03-26 17:23:42 +01:00
|
|
|
|
expect(subject.body).to include("N° #{dossier.id} ")
|
|
|
|
|
expect(subject.body).to include(dossier.procedure.libelle)
|
|
|
|
|
expect(subject.body).to include("Votre compte reste activé")
|
2024-07-18 09:40:07 +02:00
|
|
|
|
expect(subject.body).to include("Depuis la page de votre dossier vous avez la possibilité de :<br>- prolonger la durée de conservation")
|
2024-03-26 17:23:42 +01:00
|
|
|
|
end
|
2020-04-01 17:08:50 +02:00
|
|
|
|
end
|
2020-04-02 15:05:16 +02:00
|
|
|
|
|
|
|
|
|
describe 'termine' do
|
|
|
|
|
let(:dossier) { create(:dossier, :accepte) }
|
|
|
|
|
|
|
|
|
|
subject { described_class.notify_near_deletion_to_user([dossier], dossier.user.email) }
|
|
|
|
|
|
2024-03-26 17:23:42 +01:00
|
|
|
|
it 'checks email subject, to, and body for correct inclusions for termine status' do
|
|
|
|
|
expect(subject.to).to eq([dossier.user.email])
|
2024-06-17 16:33:19 +02:00
|
|
|
|
expect(subject.subject).to eq("Un dossier traité va bientôt être supprimé")
|
2024-03-26 17:23:42 +01:00
|
|
|
|
expect(subject.body).to include("N° #{dossier.id} ")
|
|
|
|
|
expect(subject.body).to include(dossier.procedure.libelle)
|
|
|
|
|
expect(subject.body).to include("Votre compte reste activé")
|
|
|
|
|
expect(subject.body).to include("PDF")
|
|
|
|
|
end
|
2023-01-03 14:50:36 +01:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'multiple termines' do
|
|
|
|
|
let(:dossiers) { create_list(:dossier, 3, :accepte) }
|
|
|
|
|
|
|
|
|
|
subject { described_class.notify_near_deletion_to_user(dossiers, dossiers[0].user.email) }
|
|
|
|
|
|
2024-03-26 17:23:42 +01:00
|
|
|
|
it 'verifies email subject and body contain correct dossier numbers for multiple termine status' do
|
2024-06-17 16:33:19 +02:00
|
|
|
|
expect(subject.subject).to eq("Des dossiers traités vont bientôt être supprimés")
|
2024-03-26 17:23:42 +01:00
|
|
|
|
dossiers.each do |dossier|
|
|
|
|
|
expect(subject.body).to include("N° #{dossier.id} ")
|
|
|
|
|
end
|
|
|
|
|
end
|
2020-04-02 15:05:16 +02:00
|
|
|
|
end
|
2020-02-18 17:18:14 +01:00
|
|
|
|
end
|
2020-02-25 18:16:21 +01:00
|
|
|
|
|
|
|
|
|
describe '.notify_groupe_instructeur_changed_to_instructeur' do
|
|
|
|
|
let(:dossier) { create(:dossier) }
|
|
|
|
|
let(:instructeur) { create(:instructeur) }
|
|
|
|
|
|
|
|
|
|
subject { described_class.notify_groupe_instructeur_changed(instructeur, dossier) }
|
|
|
|
|
|
2024-03-26 17:23:42 +01:00
|
|
|
|
it 'verifies subject and body content for groupe instructeur change notification' do
|
|
|
|
|
expect(subject.subject).to eq("Le dossier nº #{dossier.id} a changé de groupe d’instructeurs")
|
|
|
|
|
expect(subject.body).to include("n° #{dossier.id}")
|
|
|
|
|
expect(subject.body).to include(dossier.procedure.libelle)
|
|
|
|
|
expect(subject.body).to include("Suite à cette modification, vous ne suivez plus ce dossier.")
|
|
|
|
|
end
|
2020-02-25 18:16:21 +01:00
|
|
|
|
end
|
2023-06-26 16:03:58 +02:00
|
|
|
|
|
|
|
|
|
describe '.notify_pending_correction' do
|
|
|
|
|
let(:procedure) { create(:procedure) }
|
|
|
|
|
let(:dossier) { create(:dossier, :en_construction, procedure:, sva_svr_decision_on:) }
|
|
|
|
|
let(:sva_svr_decision_on) { nil }
|
2023-07-12 12:00:52 +02:00
|
|
|
|
let(:reason) { :incorrect }
|
2023-06-26 16:03:58 +02:00
|
|
|
|
let(:commentaire) { create(:commentaire, dossier:) }
|
|
|
|
|
|
|
|
|
|
subject {
|
2023-07-12 12:00:52 +02:00
|
|
|
|
dossier.flag_as_pending_correction!(commentaire, reason)
|
2023-06-26 16:03:58 +02:00
|
|
|
|
described_class.with(commentaire:).notify_pending_correction
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-12 12:00:52 +02:00
|
|
|
|
context 'reason is incorrect' do
|
2024-03-26 17:23:42 +01:00
|
|
|
|
it 'checks email subject and body for corrections without Silence Vaut Accord' do
|
|
|
|
|
expect(subject.subject).to eq("Vous devez corriger votre dossier nº #{dossier.id} « #{dossier.procedure.libelle} »")
|
|
|
|
|
expect(subject.body).to include("apporter des corrections")
|
|
|
|
|
expect(subject.body).not_to include("Silence")
|
|
|
|
|
end
|
2023-06-26 16:03:58 +02:00
|
|
|
|
end
|
|
|
|
|
|
2023-07-12 12:00:52 +02:00
|
|
|
|
context 'sva with reason is incorrect' do
|
2023-06-26 16:03:58 +02:00
|
|
|
|
let(:sva_svr_decision_on) { Date.tomorrow }
|
|
|
|
|
let(:procedure) { create(:procedure, :sva) }
|
|
|
|
|
|
2024-03-26 17:23:42 +01:00
|
|
|
|
it 'includes Silence Vaut Accord and mentions suspension for incorrect reason' do
|
|
|
|
|
expect(subject.subject).to eq("Vous devez corriger votre dossier nº #{dossier.id} « #{dossier.procedure.libelle} »")
|
|
|
|
|
expect(subject.body).to include("apporter des corrections")
|
|
|
|
|
expect(subject.body).to include("Silence Vaut Accord")
|
|
|
|
|
expect(subject.body).to include("suspendu")
|
|
|
|
|
end
|
2023-06-26 16:03:58 +02:00
|
|
|
|
end
|
|
|
|
|
|
2023-07-12 12:00:52 +02:00
|
|
|
|
context 'sva with reason is incomplete' do
|
2023-06-26 16:03:58 +02:00
|
|
|
|
let(:sva_svr_decision_on) { Date.tomorrow }
|
2023-07-12 12:00:52 +02:00
|
|
|
|
let(:reason) { :incomplete }
|
2023-06-26 16:03:58 +02:00
|
|
|
|
let(:procedure) { create(:procedure, :sva) }
|
|
|
|
|
|
2024-03-26 17:23:42 +01:00
|
|
|
|
it 'mentions the need to complete the dossier and includes Silence Vaut Accord with reset message' do
|
|
|
|
|
expect(subject.body).to include("compléter")
|
|
|
|
|
expect(subject.body).to include("Silence Vaut Accord")
|
|
|
|
|
expect(subject.body).to include("réinitialisé")
|
|
|
|
|
end
|
2023-06-26 16:03:58 +02:00
|
|
|
|
end
|
|
|
|
|
|
2023-07-12 12:00:52 +02:00
|
|
|
|
context 'svr with reason is incomplete' do
|
2023-06-26 16:03:58 +02:00
|
|
|
|
let(:sva_svr_decision_on) { Date.tomorrow }
|
2023-07-12 12:00:52 +02:00
|
|
|
|
let(:reason) { :incomplete }
|
2023-06-26 16:03:58 +02:00
|
|
|
|
let(:procedure) { create(:procedure, :svr) }
|
|
|
|
|
|
2024-03-26 17:23:42 +01:00
|
|
|
|
it 'mentions the need to complete the dossier and includes Silence Vaut Rejet with reset message' do
|
|
|
|
|
expect(subject.body).to include("compléter")
|
|
|
|
|
expect(subject.body).to include("Silence Vaut Rejet")
|
|
|
|
|
expect(subject.body).to include("réinitialisé")
|
|
|
|
|
end
|
2023-06-26 16:03:58 +02:00
|
|
|
|
end
|
|
|
|
|
end
|
2023-12-21 16:27:50 +01:00
|
|
|
|
|
|
|
|
|
describe 'notify_transfer' do
|
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
let(:procedure) { create(:procedure) }
|
|
|
|
|
let(:dossier_transfer) { create(:dossier_transfer) }
|
|
|
|
|
let!(:dossier) { create(:dossier, user: user, transfer: dossier_transfer, procedure: procedure) }
|
|
|
|
|
|
2024-01-24 16:02:09 +01:00
|
|
|
|
subject { described_class.with(dossier_transfer: dossier_transfer).notify_transfer }
|
2023-12-21 16:27:50 +01:00
|
|
|
|
|
|
|
|
|
context 'when it is a transfer of one dossier' do
|
2024-03-26 17:23:42 +01:00
|
|
|
|
it 'includes relevant details about the single dossier transfer request' do
|
|
|
|
|
expect(subject.subject).to include("Vous avez une demande de transfert en attente.")
|
|
|
|
|
expect(subject.body).to include("#{user.email} vous adresse une demande de transfert pour le dossier n° #{dossier.id} sur la démarche")
|
|
|
|
|
expect(subject.body).to include(procedure.libelle.to_s)
|
|
|
|
|
end
|
2023-12-21 16:27:50 +01:00
|
|
|
|
end
|
|
|
|
|
|
2024-03-27 09:16:40 +01:00
|
|
|
|
context 'when recipient has preferred domain' do
|
|
|
|
|
let(:dossier_transfer) { create(:dossier_transfer, email: create(:user, preferred_domain: :demarches_gouv_fr).email) }
|
2024-03-26 17:23:42 +01:00
|
|
|
|
it 'includes a link with the preferred domain in the email body' do
|
2024-04-18 18:16:22 +02:00
|
|
|
|
expect(subject.body).to include(dossiers_url(statut: "dossiers-transferes", host: 'demarches.gouv.fr'))
|
2024-03-26 17:23:42 +01:00
|
|
|
|
end
|
2024-03-27 09:16:40 +01:00
|
|
|
|
end
|
|
|
|
|
|
2023-12-21 16:27:50 +01:00
|
|
|
|
context 'when it is a transfer of multiple dossiers' do
|
|
|
|
|
let!(:dossier2) { create(:dossier, user: user, transfer: dossier_transfer, procedure: procedure) }
|
2024-03-26 17:23:42 +01:00
|
|
|
|
it 'includes a summary of multiple dossiers transfer request' do
|
|
|
|
|
expect(subject.subject).to include("Vous avez une demande de transfert en attente.")
|
|
|
|
|
expect(subject.body).to include("#{user.email} vous adresse une demande de transfert pour 2 dossiers.")
|
|
|
|
|
end
|
2023-12-21 16:27:50 +01:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'when it is a transfer of one dossier from super admin' do
|
|
|
|
|
before do
|
|
|
|
|
dossier_transfer.update!(from_support: true)
|
|
|
|
|
end
|
|
|
|
|
|
2024-03-26 17:23:42 +01:00
|
|
|
|
it 'includes details indicating the transfer request is from support' do
|
|
|
|
|
expect(subject.subject).to include("Vous avez une demande de transfert en attente.")
|
|
|
|
|
expect(subject.body).to include("Le support technique vous adresse une demande de transfert")
|
|
|
|
|
end
|
2023-12-21 16:27:50 +01:00
|
|
|
|
end
|
2024-01-24 16:02:09 +01:00
|
|
|
|
|
|
|
|
|
context 'when dossiers have been dissociated from transfer' do
|
|
|
|
|
before do
|
|
|
|
|
dossier.update!(transfer: nil)
|
|
|
|
|
dossier_transfer.reload
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'does not send an email' do
|
|
|
|
|
expect { subject.perform_now }.not_to raise_error
|
|
|
|
|
end
|
|
|
|
|
end
|
2023-12-21 16:27:50 +01:00
|
|
|
|
end
|
2018-07-16 14:39:04 +02:00
|
|
|
|
end
|