From 56cb8cbbe9ac84bec28214c65184aad5a454958c Mon Sep 17 00:00:00 2001 From: Cory Streiff <90390502+coalest@users.noreply.github.com> Date: Tue, 10 Dec 2024 02:37:17 +0100 Subject: [PATCH] Fix time zone flakiness in distribution by county specs (#4825) --- .../distributions_by_county_report_service_spec.rb | 2 +- spec/support/distribution_by_county_shared_example.rb | 2 +- spec/system/distributions_by_county_system_spec.rb | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/services/distributions_by_county_report_service_spec.rb b/spec/services/distributions_by_county_report_service_spec.rb index 1b330722ee..2a7a20e657 100644 --- a/spec/services/distributions_by_county_report_service_spec.rb +++ b/spec/services/distributions_by_county_report_service_spec.rb @@ -1,6 +1,6 @@ RSpec.describe DistributionByCountyReportService, type: :service do let(:year) { Time.current.year } - let(:issued_at_last_year) { Time.current.utc.change(year: year - 1).to_datetime } + let(:issued_at_last_year) { Time.current.change(year: year - 1).to_datetime } let(:distributions) { [] } include_examples "distribution_by_county" diff --git a/spec/support/distribution_by_county_shared_example.rb b/spec/support/distribution_by_county_shared_example.rb index 89ff48a9a2..5ae26c67ad 100644 --- a/spec/support/distribution_by_county_shared_example.rb +++ b/spec/support/distribution_by_county_shared_example.rb @@ -6,7 +6,7 @@ let(:organization_admin) { create(:organization_admin, organization: organization) } let(:item_1) { create(:item, value_in_cents: 1050, organization: organization) } - let(:issued_at_present) { Time.current.utc.to_datetime } + let(:issued_at_present) { Time.current.to_datetime } let(:partner_1) { p1 = create(:partner, organization: organization) p1.profile.served_areas << create_list(:partners_served_area, 4, partner_profile: p1.profile, client_share: 25) diff --git a/spec/system/distributions_by_county_system_spec.rb b/spec/system/distributions_by_county_system_spec.rb index 82006de4a3..808e7fa29a 100644 --- a/spec/system/distributions_by_county_system_spec.rb +++ b/spec/system/distributions_by_county_system_spec.rb @@ -2,7 +2,7 @@ include_examples "distribution_by_county" let(:current_year) { Time.current.year } - let(:issued_at_last_year) { Time.current.utc.change(year: current_year - 1).to_datetime } + let(:issued_at_last_year) { Time.current.change(year: current_year - 1).to_datetime } before do sign_in(user) @@ -39,7 +39,7 @@ it("works for prior year") do # Should NOT return distribution issued before previous calendar year - last_day_of_two_years_ago = Time.current.utc.change(year: current_year - 2, month: 12, day: 31).to_datetime + last_day_of_two_years_ago = Time.current.beginning_of_day.change(year: current_year - 2, month: 12, day: 31).to_datetime create(:distribution, :with_items, item: item_1, organization: user.organization, partner: partner_1, issued_at: last_day_of_two_years_ago) # Should return distribution issued during previous calendar year @@ -47,7 +47,7 @@ create(:distribution, :with_items, item: item_1, organization: user.organization, partner: partner_1, issued_at: one_year_ago) # Should NOT return distribution issued after previous calendar year - first_day_of_current_year = Time.current.utc.change(year: current_year, month: 1, day: 1).to_datetime + first_day_of_current_year = Time.current.end_of_day.change(year: current_year, month: 1, day: 1).to_datetime create(:distribution, :with_items, item: item_1, organization: user.organization, partner: partner_1, issued_at: first_day_of_current_year) visit_distribution_by_county_with_specified_date_range("Prior Year") @@ -61,7 +61,7 @@ it("works for last 12 months") do # Should NOT return disitribution issued before 12 months ago - one_year_and_one_day_ago = 1.year.ago.prev_day.to_datetime + one_year_and_one_day_ago = 1.year.ago.prev_day.beginning_of_day.to_datetime create(:distribution, :with_items, item: item_1, organization: user.organization, partner: partner_1, issued_at: one_year_and_one_day_ago) # Should return distribution issued during previous 12 months @@ -69,7 +69,7 @@ create(:distribution, :with_items, item: item_1, organization: user.organization, partner: partner_1, issued_at: today) # Should NOT return distribution issued in the future - tomorrow = 1.day.from_now.to_datetime + tomorrow = 1.day.from_now.end_of_day.to_datetime create(:distribution, :with_items, item: item_1, organization: user.organization, partner: partner_1, issued_at: tomorrow) visit_distribution_by_county_with_specified_date_range("Last 12 Months")