From f0b6403c1d3d1b4814c97c546d801d5bb514517e Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 10 Oct 2024 09:58:01 +1100 Subject: [PATCH] Fix locally flaky spec around date filters This spec would fail on Australian systems early in the morning or in other timezones accordingly. --- .../spec/services/affiliate_sales_query_spec.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/engines/dfc_provider/spec/services/affiliate_sales_query_spec.rb b/engines/dfc_provider/spec/services/affiliate_sales_query_spec.rb index f1ab830977..4ae4b91954 100644 --- a/engines/dfc_provider/spec/services/affiliate_sales_query_spec.rb +++ b/engines/dfc_provider/spec/services/affiliate_sales_query_spec.rb @@ -11,6 +11,13 @@ RSpec.describe AffiliateSalesQuery do let(:yesterday) { Time.zone.yesterday } let(:tomorrow) { Time.zone.tomorrow } + around do |example| + # Query dates are interpreted as UTC while the spec runs in + # Melbourne time. At noon in Melbourne, the date is the same. + # That simplifies the spec. + Timecop.travel(Time.zone.today.noon, &example) + end + it "returns data" do # Test data creation takes time. # So I'm executing more tests in one `it` block here.