diff options
-rw-r--r-- | perllib/FixMyStreet/Integrations/ExorRDI.pm | 8 | ||||
-rw-r--r-- | t/cobrand/oxfordshire.t | 12 |
2 files changed, 15 insertions, 5 deletions
diff --git a/perllib/FixMyStreet/Integrations/ExorRDI.pm b/perllib/FixMyStreet/Integrations/ExorRDI.pm index fc7e9d673..093688e47 100644 --- a/perllib/FixMyStreet/Integrations/ExorRDI.pm +++ b/perllib/FixMyStreet/Integrations/ExorRDI.pm @@ -42,8 +42,11 @@ sub construct { my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker('oxfordshire')->new; my $dtf = $cobrand->problems->result_source->storage->datetime_parser; + my $now = DateTime->now( + time_zone => FixMyStreet->time_zone || FixMyStreet->local_time_zone + ); - my $missed_cutoff = DateTime->now - DateTime::Duration->new( hours => 24 ); + my $missed_cutoff = $now - DateTime::Duration->new( hours => 24 ); my %params = ( -and => [ state => [ 'action scheduled' ], @@ -210,10 +213,9 @@ sub construct { if ($self->mark_as_processed) { # Mark all these problems are having been included in an RDI - my $now = DateTime->now->strftime( '%Y-%m-%d %H:%M' ); $problems->reset; while ( my $report = $problems->next ) { - $report->set_extra_metadata('rdi_processed' => $now); + $report->set_extra_metadata('rdi_processed' => $now->strftime( '%Y-%m-%d %H:%M' )); $report->update; } } diff --git a/t/cobrand/oxfordshire.t b/t/cobrand/oxfordshire.t index e6c16950c..a79a8f2a4 100644 --- a/t/cobrand/oxfordshire.t +++ b/t/cobrand/oxfordshire.t @@ -1,3 +1,5 @@ + +use Test::MockModule; use FixMyStreet::Integrations::ExorRDI; use FixMyStreet::TestMech; @@ -158,6 +160,13 @@ subtest 'Reports are marked as inspected correctly' => sub { ALLOWED_COBRANDS => [ 'oxfordshire' ], }, sub { my $date = DateTime->new(year => 2017, month => 5, day => 5, hour => 12); + + my $now = DateTime->now( + time_zone => FixMyStreet->time_zone || FixMyStreet->local_time_zone + ); + my $datetime = Test::MockModule->new('DateTime'); + $datetime->mock('now', sub { $now }); + my $params = { start_date => $date, end_date => $date, @@ -168,10 +177,9 @@ subtest 'Reports are marked as inspected correctly' => sub { my $rdi = FixMyStreet::Integrations::ExorRDI->new($params); $rdi->construct; - my $now = DateTime->now->strftime( '%Y-%m-%d %H:%M' ); foreach my $problem (@problems) { $problem->discard_changes; - is $problem->get_extra_metadata('rdi_processed'), $now, "Problem was logged as sent in RDI"; + is $problem->get_extra_metadata('rdi_processed'), $now->strftime( '%Y-%m-%d %H:%M' ), "Problem was logged as sent in RDI"; } }; }; |