diff --git a/perllib/Open311/UpdatesBase.pm b/perllib/Open311/UpdatesBase.pm index 2eb7d82a0f..90071f8707 100644 --- a/perllib/Open311/UpdatesBase.pm +++ b/perllib/Open311/UpdatesBase.pm @@ -281,7 +281,9 @@ sub _process_update { # insertion. We also then need a clone, otherwise the setting of lastupdate # will *also* reshift comment->created's time zone to TIME_ZONE. my $created = $comment->created->set_time_zone(FixMyStreet->local_time_zone); - $p->lastupdate($created->clone); + if ($created > $p->lastupdate) { + $p->lastupdate($created->clone); + } return $comment unless $self->commit; diff --git a/t/cobrand/brent.t b/t/cobrand/brent.t index 920cd8fe2d..cc008de90e 100644 --- a/t/cobrand/brent.t +++ b/t/cobrand/brent.t @@ -762,6 +762,8 @@ subtest 'push updating of reports' => sub { ($report, $report2) = $mech->create_problems_for_body(2, $brent->id, 'Graffiti', { category => 'Graffiti', }); + # Set last update to before the time of the first update we've mocked. + $report->update({ lastupdate => DateTime->new(year => 2020, month => 06, day => 23, hour => 15) }); my $report_id = $report->id; my $cobrand = FixMyStreet::Cobrand::Brent->new; diff --git a/t/cobrand/bromley_waste.t b/t/cobrand/bromley_waste.t index 582a568c0b..345ac66a03 100644 --- a/t/cobrand/bromley_waste.t +++ b/t/cobrand/bromley_waste.t @@ -582,6 +582,8 @@ subtest 'updating of waste reports' => sub { }); $reports[1]->update({ external_id => 'something-else' }); # To test loop $report = $reports[0]; + # Set last update to before the time of the first update we've mocked. + $report->update({ lastupdate => DateTime->new(year => 2020, month => 06, day => 23, hour => 15) }); my $cobrand = FixMyStreet::Cobrand::Bromley->new; $report->update({ external_id => 'waste-15001-' }); diff --git a/t/cobrand/sutton.t b/t/cobrand/sutton.t index 1b2e987622..3ad436a1ae 100644 --- a/t/cobrand/sutton.t +++ b/t/cobrand/sutton.t @@ -16,6 +16,7 @@ FixMyStreet::App->log->disable('info'); END { FixMyStreet::App->log->enable('info'); } # Create test data +my $date = DateTime->now->subtract(days => 1)->strftime('%Y-%m-%dT%H:%M:%SZ'); my $user = $mech->create_user_ok( 'sutton@example.com', name => 'Sutton Council' ); my $normal_user = $mech->create_user_ok( 'user@example.com', name => 'Norma Normal' ); my $body = $mech->create_body_ok( 2498, 'Sutton Council', { @@ -167,7 +168,6 @@ sub new { my $c = shift; bless { @_ }, $c; } package main; subtest 'updating of waste reports' => sub { - my $date = DateTime->now->subtract(days => 1)->strftime('%Y-%m-%dT%H:%M:%SZ'); my $integ = Test::MockModule->new('SOAP::Lite'); $integ->mock(call => sub { my ($cls, @args) = @_; @@ -216,6 +216,8 @@ subtest 'updating of waste reports' => sub { }); $reports[1]->update({ external_id => 'something-else' }); # To test loop $report = $reports[0]; + # Set last update to before the time of the first update we've mocked. + $report->update({ lastupdate => $date }); FixMyStreet::override_config { ALLOWED_COBRANDS => 'sutton',