Skip to content

Commit 604088d

Browse files
authored
fix: use date safely within validation window in organization spec (#5535)
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.
1 parent 4416b13 commit 604088d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

spec/models/organization_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,9 @@
404404

405405
it 'is the year of the earliest of donation, purchase, or distribution if they are earlier ' do
406406
freeze_time do
407-
create(:donation, organization: organization, issued_at: DateTime.current.next_year - 1.day)
408-
create(:purchase, organization: organization, issued_at: DateTime.current.next_year - 1.day)
409-
create(:distribution, organization: organization, issued_at: DateTime.current.next_year - 1.day)
407+
create(:donation, organization: organization, issued_at: 6.months.from_now)
408+
create(:purchase, organization: organization, issued_at: 6.months.from_now)
409+
create(:distribution, organization: organization, issued_at: 6.months.from_now)
410410
expect(organization.earliest_reporting_year).to eq(organization.created_at.year)
411411
create(:donation, organization: organization, issued_at: 5.years.ago)
412412
expect(organization.earliest_reporting_year).to eq(5.years.ago.year)

0 commit comments

Comments
 (0)