fix(dossier): send expiration notifications 2 weeks prior to supression instead of a month
This commit is contained in:
parent
dad9c0473c
commit
8e1bfb469f
6 changed files with 31 additions and 31 deletions
|
@ -57,7 +57,7 @@ class Dossier < ApplicationRecord
|
|||
|
||||
REMAINING_DAYS_BEFORE_CLOSING = 2
|
||||
INTERVAL_BEFORE_CLOSING = "#{REMAINING_DAYS_BEFORE_CLOSING} days"
|
||||
INTERVAL_BEFORE_EXPIRATION = '1 month'
|
||||
INTERVAL_BEFORE_EXPIRATION = '2 weeks'
|
||||
INTERVAL_EXPIRATION = '1 month 5 days'
|
||||
|
||||
has_one :etablissement, dependent: :destroy
|
||||
|
|
|
@ -14,8 +14,8 @@ fr:
|
|||
one: "Le dossier suivant dont le traitement est terminé sera bientôt automatiquement supprimé :"
|
||||
other: "Les dossiers suivant dont le traitement est terminé seront bientôt automatiquement supprimés :"
|
||||
footer_en_construction:
|
||||
one: "Vous avez <b>un mois</b> pour commencer l’instruction du dossier."
|
||||
other: "Vous avez <b>un mois</b> pour commencer l’instruction des dossiers."
|
||||
one: "Vous avez <b>deux semaines</b> pour commencer l’instruction du dossier."
|
||||
other: "Vous avez <b>deux semaines</b> pour commencer l’instruction des dossiers."
|
||||
footer_termine:
|
||||
one: "Vous avez <b>un mois</b> pour archiver le dossier."
|
||||
other: "Vous avez <b>un mois</b> pour archiver les dossiers."
|
||||
one: "Vous avez <b>deux semaines</b> pour archiver le dossier."
|
||||
other: "Vous avez <b>deux semaines</b> pour archiver les dossiers."
|
||||
|
|
|
@ -14,8 +14,8 @@ fr:
|
|||
one: "Afin de limiter la conservation de vos données personnelles, le dossier suivant dont le traitement est terminé sera bientôt automatiquement supprimé :"
|
||||
other: "Afin de limiter la conservation de vos données personnelles, les dossiers suivant dont le traitement est terminé seront bientôt automatiquement supprimés :"
|
||||
footer:
|
||||
one: "Vous pouvez retrouver votre dossier pendant encore <b>un mois</b>. Vous n’avez rien à faire."
|
||||
other: "Vous pouvez retrouver vos dossiers pendant encore <b>un mois</b>. Vous n’avez rien à faire."
|
||||
one: "Vous pouvez retrouver votre dossier pendant encore <b>deux semaines</b>. Vous n’avez rien à faire."
|
||||
other: "Vous pouvez retrouver vos dossiers pendant encore <b>deux semaines</b>. Vous n’avez rien à faire."
|
||||
footer_en_construction:
|
||||
one: "Si vous souhaitez conserver votre dossier plus longtemps, vous pouvez <b>prolonger sa durée de conservation</b> dans l’interface."
|
||||
other: "Si vous souhaitez conserver vos dossiers plus longtemps, vous pouvez <b>prolonger leur durée de conservation</b> au cas par cas dans l’interface."
|
||||
|
|
|
@ -151,7 +151,7 @@ RSpec.describe DossierMailer, type: :mailer do
|
|||
it { expect(subject.body).to include("n° #{dossier.id} ") }
|
||||
it { expect(subject.body).to include(dossier.procedure.libelle) }
|
||||
it { expect(subject.body).to include("PDF") }
|
||||
it { expect(subject.body).to include("Vous avez <b>un mois</b> pour commencer l’instruction du dossier.") }
|
||||
it { expect(subject.body).to include("Vous avez <b>deux semaines</b> pour commencer l’instruction du dossier.") }
|
||||
end
|
||||
|
||||
describe 'termine' do
|
||||
|
@ -163,7 +163,7 @@ RSpec.describe DossierMailer, type: :mailer do
|
|||
it { expect(subject.body).to include("n° #{dossier.id} ") }
|
||||
it { expect(subject.body).to include(dossier.procedure.libelle) }
|
||||
it { expect(subject.body).to include("PDF") }
|
||||
it { expect(subject.body).to include("Vous avez <b>un mois</b> pour archiver le dossier.") }
|
||||
it { expect(subject.body).to include("Vous avez <b>deux semaines</b> pour archiver le dossier.") }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -178,7 +178,7 @@ RSpec.describe DossierMailer, type: :mailer do
|
|||
it { expect(subject.body).to include("n° #{dossier.id} ") }
|
||||
it { expect(subject.body).to include(dossier.procedure.libelle) }
|
||||
it { expect(subject.body).to include("PDF") }
|
||||
it { expect(subject.body).to include("Vous pouvez retrouver votre dossier pendant encore <b>un mois</b>. Vous n’avez rien à faire.") }
|
||||
it { expect(subject.body).to include("Vous pouvez retrouver votre dossier pendant encore <b>deux semaines</b>. Vous n’avez rien à faire.") }
|
||||
it { expect(subject.body).to include("Si vous souhaitez conserver votre dossier plus longtemps, vous pouvez <b>prolonger sa durée de conservation</b> dans l’interface.") }
|
||||
end
|
||||
|
||||
|
@ -192,7 +192,7 @@ RSpec.describe DossierMailer, type: :mailer do
|
|||
it { expect(subject.body).to include("n° #{dossier.id} ") }
|
||||
it { expect(subject.body).to include(dossier.procedure.libelle) }
|
||||
it { expect(subject.body).to include("PDF") }
|
||||
it { expect(subject.body).to include("Vous pouvez retrouver votre dossier pendant encore <b>un mois</b>. Vous n’avez rien à faire.") }
|
||||
it { expect(subject.body).to include("Vous pouvez retrouver votre dossier pendant encore <b>deux semaines</b>. Vous n’avez rien à faire.") }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ describe Dossier do
|
|||
describe 'brouillon_close_to_expiration' do
|
||||
let(:procedure) { create(:procedure, :published, duree_conservation_dossiers_dans_ds: 6) }
|
||||
let!(:young_dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
||||
let!(:expiring_dossier) { create(:dossier, created_at: 170.days.ago, procedure: procedure) }
|
||||
let!(:expiring_dossier) { create(:dossier, created_at: 175.days.ago, procedure: procedure) }
|
||||
let!(:just_expired_dossier) { create(:dossier, created_at: (6.months + 1.hour + 10.seconds).ago, procedure: procedure) }
|
||||
let!(:long_expired_dossier) { create(:dossier, created_at: 1.year.ago, procedure: procedure) }
|
||||
|
||||
|
@ -66,7 +66,7 @@ describe Dossier do
|
|||
describe 'en_construction_close_to_expiration' do
|
||||
let(:procedure) { create(:procedure, :published, duree_conservation_dossiers_dans_ds: 6) }
|
||||
let!(:young_dossier) { create(:dossier, procedure: procedure) }
|
||||
let!(:expiring_dossier) { create(:dossier, :en_construction, en_construction_at: 170.days.ago, procedure: procedure) }
|
||||
let!(:expiring_dossier) { create(:dossier, :en_construction, en_construction_at: 175.days.ago, procedure: procedure) }
|
||||
let!(:just_expired_dossier) { create(:dossier, :en_construction, en_construction_at: (6.months + 1.hour + 10.seconds).ago, procedure: procedure) }
|
||||
let!(:long_expired_dossier) { create(:dossier, :en_construction, en_construction_at: 1.year.ago, procedure: procedure) }
|
||||
|
||||
|
@ -92,7 +92,7 @@ describe Dossier do
|
|||
describe 'en_instruction_close_to_expiration' do
|
||||
let(:procedure) { create(:procedure, :published, duree_conservation_dossiers_dans_ds: 6) }
|
||||
let!(:young_dossier) { create(:dossier, procedure: procedure) }
|
||||
let!(:expiring_dossier) { create(:dossier, :en_instruction, en_instruction_at: 170.days.ago, procedure: procedure) }
|
||||
let!(:expiring_dossier) { create(:dossier, :en_instruction, en_instruction_at: 175.days.ago, procedure: procedure) }
|
||||
let!(:just_expired_dossier) { create(:dossier, :en_instruction, en_instruction_at: (6.months + 1.hour + 10.seconds).ago, procedure: procedure) }
|
||||
let!(:long_expired_dossier) { create(:dossier, :en_instruction, en_instruction_at: 1.year.ago, procedure: procedure) }
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ describe ExpiredDossiersDeletionService do
|
|||
|
||||
describe '#process_expired_dossiers_brouillon' do
|
||||
let(:today) { Time.zone.now.at_midnight }
|
||||
let(:date_close_to_expiration) { Date.today - procedure.duree_conservation_dossiers_dans_ds.months + 1.month }
|
||||
let(:date_close_to_expiration) { Date.today - procedure.duree_conservation_dossiers_dans_ds.months + 2.weeks }
|
||||
let(:date_expired) { Date.today - procedure.duree_conservation_dossiers_dans_ds.months - 6.days }
|
||||
let(:date_not_expired) { Date.today - procedure.duree_conservation_dossiers_dans_ds.months + 2.months }
|
||||
|
||||
|
@ -56,15 +56,15 @@ describe ExpiredDossiersDeletionService do
|
|||
|
||||
before { ExpiredDossiersDeletionService.send_brouillon_expiration_notices }
|
||||
|
||||
context 'when the dossier is not closed to expiration' do
|
||||
let(:created_at) { (conservation_par_defaut - 1.month - 1.day).ago }
|
||||
context 'when the dossier is not close to expiration' do
|
||||
let(:created_at) { (conservation_par_defaut - 2.weeks - 1.day).ago }
|
||||
|
||||
it { expect(dossier.reload.brouillon_close_to_expiration_notice_sent_at).to be_nil }
|
||||
it { expect(DossierMailer).not_to have_received(:notify_brouillon_near_deletion) }
|
||||
end
|
||||
|
||||
context 'when the dossier is closed to expiration' do
|
||||
let(:created_at) { (conservation_par_defaut - 1.month + 1.day).ago }
|
||||
context 'when the dossier is close to expiration' do
|
||||
let(:created_at) { (conservation_par_defaut - 2.weeks + 1.day).ago }
|
||||
|
||||
it { expect(dossier.reload.brouillon_close_to_expiration_notice_sent_at).not_to be_nil }
|
||||
it { expect(DossierMailer).to have_received(:notify_brouillon_near_deletion).once }
|
||||
|
@ -73,8 +73,8 @@ describe ExpiredDossiersDeletionService do
|
|||
end
|
||||
|
||||
context 'with 2 dossiers to notice' do
|
||||
let!(:dossier_1) { create(:dossier, procedure: procedure, user: user, created_at: (conservation_par_defaut - 1.month + 1.day).ago) }
|
||||
let!(:dossier_2) { create(:dossier, procedure: procedure_2, user: user, created_at: (conservation_par_defaut - 1.month + 1.day).ago) }
|
||||
let!(:dossier_1) { create(:dossier, procedure: procedure, user: user, created_at: (conservation_par_defaut - 2.weeks + 1.day).ago) }
|
||||
let!(:dossier_2) { create(:dossier, procedure: procedure_2, user: user, created_at: (conservation_par_defaut - 2.weeks + 1.day).ago) }
|
||||
|
||||
before { ExpiredDossiersDeletionService.send_brouillon_expiration_notices }
|
||||
|
||||
|
@ -146,7 +146,7 @@ describe ExpiredDossiersDeletionService do
|
|||
before { ExpiredDossiersDeletionService.send_en_construction_expiration_notices }
|
||||
|
||||
context 'when the dossier is not near deletion' do
|
||||
let(:en_construction_at) { (conservation_par_defaut - 1.month - 1.day).ago }
|
||||
let(:en_construction_at) { (conservation_par_defaut - 2.weeks - 1.day).ago }
|
||||
|
||||
it { expect(dossier.reload.en_construction_close_to_expiration_notice_sent_at).to be_nil }
|
||||
it { expect(DossierMailer).not_to have_received(:notify_near_deletion_to_user) }
|
||||
|
@ -154,7 +154,7 @@ describe ExpiredDossiersDeletionService do
|
|||
end
|
||||
|
||||
context 'when the dossier is near deletion' do
|
||||
let(:en_construction_at) { (conservation_par_defaut - 1.month + 1.day).ago }
|
||||
let(:en_construction_at) { (conservation_par_defaut - 2.weeks + 1.day).ago }
|
||||
|
||||
it { expect(dossier.reload.en_construction_close_to_expiration_notice_sent_at).not_to be_nil }
|
||||
|
||||
|
@ -167,8 +167,8 @@ describe ExpiredDossiersDeletionService do
|
|||
end
|
||||
|
||||
context 'with 2 dossiers to notice' do
|
||||
let!(:dossier_1) { create(:dossier, :en_construction, procedure: procedure, user: user, en_construction_at: (conservation_par_defaut - 1.month + 1.day).ago) }
|
||||
let!(:dossier_2) { create(:dossier, :en_construction, procedure: procedure_2, user: user, en_construction_at: (conservation_par_defaut - 1.month + 1.day).ago) }
|
||||
let!(:dossier_1) { create(:dossier, :en_construction, procedure: procedure, user: user, en_construction_at: (conservation_par_defaut - 2.weeks + 1.day).ago) }
|
||||
let!(:dossier_2) { create(:dossier, :en_construction, procedure: procedure_2, user: user, en_construction_at: (conservation_par_defaut - 2.weeks + 1.day).ago) }
|
||||
|
||||
let!(:instructeur) { create(:instructeur) }
|
||||
|
||||
|
@ -187,7 +187,7 @@ describe ExpiredDossiersDeletionService do
|
|||
|
||||
context 'when an instructeur is also administrateur' do
|
||||
let!(:administrateur) { procedure.administrateurs.first }
|
||||
let!(:dossier) { create(:dossier, :en_construction, procedure: procedure, en_construction_at: (conservation_par_defaut - 1.month + 1.day).ago) }
|
||||
let!(:dossier) { create(:dossier, :en_construction, procedure: procedure, en_construction_at: (conservation_par_defaut - 2.weeks + 1.day).ago) }
|
||||
|
||||
before do
|
||||
administrateur.instructeur.followed_dossiers << dossier
|
||||
|
@ -290,7 +290,7 @@ describe ExpiredDossiersDeletionService do
|
|||
before { ExpiredDossiersDeletionService.send_termine_expiration_notices }
|
||||
|
||||
context 'when the dossier is not near deletion' do
|
||||
let(:processed_at) { (conservation_par_defaut - 1.month - 1.day).ago }
|
||||
let(:processed_at) { (conservation_par_defaut - 2.weeks - 1.day).ago }
|
||||
|
||||
it { expect(dossier.reload.termine_close_to_expiration_notice_sent_at).to be_nil }
|
||||
it { expect(DossierMailer).not_to have_received(:notify_near_deletion_to_user) }
|
||||
|
@ -298,7 +298,7 @@ describe ExpiredDossiersDeletionService do
|
|||
end
|
||||
|
||||
context 'when the dossier is near deletion' do
|
||||
let(:processed_at) { (conservation_par_defaut - 1.month + 1.day).ago }
|
||||
let(:processed_at) { (conservation_par_defaut - 2.weeks + 1.day).ago }
|
||||
|
||||
it { expect(dossier.reload.termine_close_to_expiration_notice_sent_at).not_to be_nil }
|
||||
|
||||
|
@ -311,8 +311,8 @@ describe ExpiredDossiersDeletionService do
|
|||
end
|
||||
|
||||
context 'with 2 dossiers to notice' do
|
||||
let!(:dossier_1) { create(:dossier, :accepte, procedure: procedure, user: user, processed_at: (conservation_par_defaut - 1.month + 1.day).ago) }
|
||||
let!(:dossier_2) { create(:dossier, :accepte, procedure: procedure_2, user: user, processed_at: (conservation_par_defaut - 1.month + 1.day).ago) }
|
||||
let!(:dossier_1) { create(:dossier, :accepte, procedure: procedure, user: user, processed_at: (conservation_par_defaut - 2.weeks + 1.day).ago) }
|
||||
let!(:dossier_2) { create(:dossier, :accepte, procedure: procedure_2, user: user, processed_at: (conservation_par_defaut - 2.weeks + 1.day).ago) }
|
||||
|
||||
let!(:instructeur) { create(:instructeur) }
|
||||
|
||||
|
@ -331,7 +331,7 @@ describe ExpiredDossiersDeletionService do
|
|||
|
||||
context 'when an instructeur is also administrateur' do
|
||||
let!(:administrateur) { procedure.administrateurs.first }
|
||||
let!(:dossier) { create(:dossier, :accepte, procedure: procedure, processed_at: (conservation_par_defaut - 1.month + 1.day).ago) }
|
||||
let!(:dossier) { create(:dossier, :accepte, procedure: procedure, processed_at: (conservation_par_defaut - 2.weeks + 1.day).ago) }
|
||||
|
||||
before do
|
||||
administrateur.instructeur.followed_dossiers << dossier
|
||||
|
|
Loading…
Reference in a new issue