aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2019-04-25 17:09:31 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2019-05-02 22:07:26 +0100
commit54cad1e4d2474fba55485731ca9e2fd1779c524a (patch)
tree0b1e765b8bac8b50953038cf6ae25b1aa312e0d1 /t
parent4b4da81ffec527df9741c960d79294b48bb4dcaa (diff)
Fix some incorrect timezone code.
Times in the database should be stored in the application server's local timezone, by e.g. using `current_timestamp`, or by setting that timezone explicitly before storage (the database columns are all without timezone so any timezone info is silently ignored). Reports & updates fetched via Open311 and offline updates were being put into the TIME_ZONE setting if present, meaning they were stored incorrectly for future usage.
Diffstat (limited to 't')
-rw-r--r--t/app/controller/report_inspect.t2
-rw-r--r--t/open311/getservicerequests.t9
-rw-r--r--t/open311/getservicerequestupdates.t6
3 files changed, 9 insertions, 8 deletions
diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t
index 397dd1b00..ef05288c7 100644
--- a/t/app/controller/report_inspect.t
+++ b/t/app/controller/report_inspect.t
@@ -749,7 +749,7 @@ FixMyStreet::override_config {
# set the timezone on this so the date comparison below doesn't fail due to mismatched
# timezones
my $now = DateTime->now(
- time_zone => FixMyStreet->time_zone || FixMyStreet->local_time_zone
+ time_zone => FixMyStreet->local_time_zone
)->subtract(days => 1);
$mech->submit_form(button => 'save', form_id => 'report_inspect_form',
fields => { include_update => 1, public_update => 'An update', saved_at => $now->epoch });
diff --git a/t/open311/getservicerequests.t b/t/open311/getservicerequests.t
index f4eae59b1..55bb9ba11 100644
--- a/t/open311/getservicerequests.t
+++ b/t/open311/getservicerequests.t
@@ -76,13 +76,9 @@ my $o = Open311->new(
);
my $p1_date = $dtf->parse_datetime('2010-04-14T06:37:38-08:00')
- ->set_time_zone(
- FixMyStreet->time_zone || FixMyStreet->local_time_zone
- );
+ ->set_time_zone(FixMyStreet->local_time_zone);
my $p2_date = $dtf->parse_datetime('2010-04-15T06:37:38-08:00')
- ->set_time_zone(
- FixMyStreet->time_zone || FixMyStreet->local_time_zone
- );
+ ->set_time_zone(FixMyStreet->local_time_zone);
my $start_date = $p1_date->clone;
$start_date->add( hours => -2);
my $end_date = $p2_date->clone;
@@ -96,6 +92,7 @@ subtest 'basic parsing checks' => sub {
end_date => $end_date
);
FixMyStreet::override_config {
+ TIME_ZONE => 'Asia/Tokyo',
MAPIT_URL => 'http://mapit.uk/',
}, sub {
$update->create_problems( $o, $body );
diff --git a/t/open311/getservicerequestupdates.t b/t/open311/getservicerequestupdates.t
index 573e23cfc..f680985a4 100644
--- a/t/open311/getservicerequestupdates.t
+++ b/t/open311/getservicerequestupdates.t
@@ -557,7 +557,11 @@ subtest 'date for comment correct' => sub {
my $o = Open311->new( jurisdiction => 'mysociety', endpoint => 'http://example.com', test_mode => 1, test_get_returns => { 'servicerequestupdates.xml' => $local_requests_xml } );
my $update = Open311::GetServiceRequestUpdates->new( system_user => $user );
- $update->update_comments( $o, $bodies{2482} );
+ FixMyStreet::override_config {
+ TIME_ZONE => 'Australia/Sydney',
+ }, sub {
+ $update->update_comments( $o, $bodies{2482} );
+ };
my $comment = $problem->comments->first;
is $comment->created, $dt, 'created date set to date from XML';