From 1c2e93ed419d29ed6a40bd9078b11346a85492cb Mon Sep 17 00:00:00 2001 From: Nicolas Bouilleaud Date: Mon, 29 Apr 2019 15:29:13 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20=E2=80=9Cnearing=5Fend=5Fof=5Fretention?= =?UTF-8?q?=E2=80=9D=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `nearing_end_of_retention` test creates a `just_expired_dossier` “six months ago”, which is 29 Oct 2018. The autumn DST change was on October 28; this is the first time this test runs under these conditions. We workaround the time offset by creating the dossier one hour earlier. This is technically a workaround, not a fix: the date arithmetics in `nearing_end_of_retention` are probably wrong. It looks like it’s comparing intervals, which seems error-prone, while it should be comparing dates. For now, I’m just making the tests pass. --- spec/models/dossier_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index 0ab8763f5..ea85160af 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -31,7 +31,7 @@ describe Dossier do let(:procedure) { create(:procedure, 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!(:just_expired_dossier) { create(:dossier, :en_instruction, en_instruction_at: (6.months + 1.second).ago, procedure: procedure) } + let!(:just_expired_dossier) { create(:dossier, :en_instruction, en_instruction_at: (6.months + 1.hour + 1.second).ago, procedure: procedure) } let!(:long_expired_dossier) { create(:dossier, :en_instruction, en_instruction_at: 1.year.ago, procedure: procedure) } context 'with default delay to end of retention' do