specs: make dossiers deletion specs more robust

It would fail when ran on some dates, like "21 Dec. 2021".
This commit is contained in:
Pierre de La Morinerie 2021-12-21 17:20:32 +01:00
parent 7478268b11
commit 4efc1053f9

View file

@ -8,10 +8,10 @@ describe ExpiredDossiersDeletionService do
let(:reference_date) { Date.parse("March 8") }
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 + 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 }
let(:today) { Time.zone.now.at_beginning_of_day }
let(:date_close_to_expiration) { today - procedure.duree_conservation_dossiers_dans_ds.months + 13.days }
let(:date_expired) { today - procedure.duree_conservation_dossiers_dans_ds.months - 6.days }
let(:date_not_expired) { today - procedure.duree_conservation_dossiers_dans_ds.months + 2.months }
context 'send messages for dossiers expiring soon and delete expired' do
let!(:expired_brouillon) { create(:dossier, procedure: procedure, created_at: date_expired, brouillon_close_to_expiration_notice_sent_at: today - (warning_period + 3.days)) }