From cfa53630e93e0be10a183a149ca4eba5424a6554 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Wed, 7 Feb 2018 10:58:48 +1300 Subject: prevent timezone related util test failure Make sure that the prettify_dt tests use the same timezone as FMS otherwise the test can fail if now in the local timezone is actually yesterday/tomorrow in the FMS timezone. Fixes #1984 --- CHANGELOG.md | 1 + t/utils.t | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 330b578c6..96f0fd35c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ - Change text on /reports to match lower down (fix translation). - Ensure all reports graph can't dip downward. #1956 - Fix error sending `requires_inspection` reports. #1961 + - Fix timezone related test failure. #1984 - Admin improvements: - Admin can anonymize/hide all a user's reports. #1942 #1943 - Admin can log a user out. #1975 diff --git a/t/utils.t b/t/utils.t index f989580c8..aeaf225c7 100644 --- a/t/utils.t +++ b/t/utils.t @@ -67,7 +67,9 @@ is Utils::cleanup_text( "This has new\n\n\nlines in it", { allow_multiline => 1 is Utils::prettify_dt(), "[unknown time]"; -my $dt = DateTime->now; +# Make sure we create the date using the FMS timezone that prettify_dt uses +# otherwise this can fail if the local timezone is not the same as the FMS one +my $dt = DateTime->now( time_zone => FixMyStreet->time_zone || FixMyStreet->local_time_zone ); is Utils::prettify_dt($dt), $dt->strftime("%H:%M today"); # Same week test -- cgit v1.2.3