From de2a49dafd2b1bb99ad944757aa0a1c1a055d68a Mon Sep 17 00:00:00 2001 From: John Costa Date: Wed, 1 Apr 2026 12:37:25 -0700 Subject: [PATCH] fix: use date safely within validation window in organization spec The test used `DateTime.current.next_year - 1.day` which is right at the boundary of the `issued_at_cannot_be_further_than_1_year` validation. This causes intermittent failures due to timing precision. Using `6.months.from_now` keeps the test intent (future date that passes validation) while staying well within the allowed window. --- spec/models/organization_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/models/organization_spec.rb b/spec/models/organization_spec.rb index ad40e1b7d6..854469d18f 100644 --- a/spec/models/organization_spec.rb +++ b/spec/models/organization_spec.rb @@ -404,9 +404,9 @@ it 'is the year of the earliest of donation, purchase, or distribution if they are earlier ' do freeze_time do - create(:donation, organization: organization, issued_at: DateTime.current.next_year - 1.day) - create(:purchase, organization: organization, issued_at: DateTime.current.next_year - 1.day) - create(:distribution, organization: organization, issued_at: DateTime.current.next_year - 1.day) + create(:donation, organization: organization, issued_at: 6.months.from_now) + create(:purchase, organization: organization, issued_at: 6.months.from_now) + create(:distribution, organization: organization, issued_at: 6.months.from_now) expect(organization.earliest_reporting_year).to eq(organization.created_at.year) create(:donation, organization: organization, issued_at: 5.years.ago) expect(organization.earliest_reporting_year).to eq(5.years.ago.year)