Skip to content

Commit

Permalink
Fix email alert on initial update template.
Browse files Browse the repository at this point in the history
A report's confirmation timestamp uses current_timestamp, and so
includes microseconds. An initial update text, to fit in with the
Open311 handling of updates, uses a DateTime object, which does not.
This means if a report is created when logged in, the initial update
can have a timestamp earlier than the report, and so is not alerted on.
  • Loading branch information
dracos committed Oct 9, 2020
1 parent 76c4765 commit 2d87d6b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
- Do not trigger duplicate check when checking stoppers
- Do not strip spaces from middle of Open311 category codes. #3167
- Show all category history even if category renamed.
- Fix email alert on initial update template.
- Admin improvements:
- Display user name/email for contributed as reports. #2990
- Interface for enabling anonymous reports for certain categories. #2989
Expand Down
5 changes: 4 additions & 1 deletion perllib/FixMyStreet/App/Controller/Report/New.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1736,7 +1736,10 @@ sub create_related_things : Private {
my $request = {
service_request_id => $problem->id,
update_id => 'auto-internal',
comment_time => DateTime->now,
# Add a second so it is definitely later than problem confirmed timestamp,
# which uses current_timestamp (and thus microseconds) whilst this update
# is rounded down to the nearest second
comment_time => DateTime->now->add( seconds => 1 ),
status => 'open',
description => $description,
};
Expand Down
4 changes: 4 additions & 0 deletions t/app/controller/report_new_update.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use FixMyStreet::TestMech;
use FixMyStreet::Script::Alerts;

# disable info logs for this test run
FixMyStreet::App->log->disable('info');
Expand Down Expand Up @@ -43,6 +44,9 @@ subtest "test report creation with initial auto-update" => sub {
is $comment->user->id, $comment_user->id;
is $comment->external_id, 'auto-internal';
is $comment->name, 'Glos Council';

FixMyStreet::Script::Alerts::send();
my $email = $mech->get_email;
};

done_testing;
Expand Down

0 comments on commit 2d87d6b

Please sign in to comment.