From c59b8fc2b82d0e8c8cb7e556455ffd67ed904b1a Mon Sep 17 00:00:00 2001 From: Matt Hinz Date: Mon, 28 Nov 2022 15:44:49 -0800 Subject: [PATCH 1/2] Fix flaky GPO exporter test Address a flaky test introduced in #7389. We run tests in CI with a random Timezone each time. This means sometimes the local day and UTC day are different, which was making the GPO exporter test fail. This change updates `GpoConfirmationExporter` to convert dates to UTC before outputting them. This gives us consistency on tests but should not matter in prod, where the Timezone is already set to UTC. For LG-8233 [skip changelog] --- app/services/gpo_confirmation_exporter.rb | 2 +- spec/services/gpo_confirmation_exporter_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/gpo_confirmation_exporter.rb b/app/services/gpo_confirmation_exporter.rb index b56a7829e23..52748cb77d1 100644 --- a/app/services/gpo_confirmation_exporter.rb +++ b/app/services/gpo_confirmation_exporter.rb @@ -54,7 +54,7 @@ def make_entry_row(confirmation) end def format_date(date) - "#{date.strftime('%-B %-e')}, #{date.year}" + date.utc.strftime('%-B %-e, %Y').to_s end def current_date diff --git a/spec/services/gpo_confirmation_exporter_spec.rb b/spec/services/gpo_confirmation_exporter_spec.rb index aba6e5a3173..ac194705b8a 100644 --- a/spec/services/gpo_confirmation_exporter_spec.rb +++ b/spec/services/gpo_confirmation_exporter_spec.rb @@ -41,7 +41,7 @@ describe '#run' do before do allow(IdentityConfig.store).to receive(:usps_confirmation_max_days).and_return(10) - allow(subject).to receive(:current_date).and_return(Time.zone.local(2018, 7, 6)) + allow(subject).to receive(:current_date).and_return(Time.utc(2018, 7, 6)) end it 'creates psv string' do From 24f623ba5d1d8517acfcf7b68d9e3027cb578927 Mon Sep 17 00:00:00 2001 From: Matt Hinz Date: Tue, 29 Nov 2022 09:05:16 -0800 Subject: [PATCH 2/2] Update app/services/gpo_confirmation_exporter.rb Co-authored-by: Zach Margolis --- app/services/gpo_confirmation_exporter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/gpo_confirmation_exporter.rb b/app/services/gpo_confirmation_exporter.rb index 52748cb77d1..009a245ed67 100644 --- a/app/services/gpo_confirmation_exporter.rb +++ b/app/services/gpo_confirmation_exporter.rb @@ -54,7 +54,7 @@ def make_entry_row(confirmation) end def format_date(date) - date.utc.strftime('%-B %-e, %Y').to_s + date.in_time_zone('UTC').strftime('%-B %-e, %Y') end def current_date