Skip to content

Commit

Permalink
[Bromley] Unset external status code when reopening Echo report.
Browse files Browse the repository at this point in the history
Without doing this, if the Echo report is closed again with the same
resolution code (which maps to external status code), the response
template is not located because that only looks for external status code
templates if the external status code has changed.
  • Loading branch information
dracos committed Jun 7, 2024
1 parent 359d970 commit bdc15c0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions perllib/FixMyStreet/Cobrand/Bromley.pm
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ sub should_skip_sending_update {
$report->update_extra_field({ name => 'Event_ID', value => $event->{Id} });
$report->set_extra_metadata('open311_category_override' => REFERRED_TO_VEOLIA);
$report->set_extra_metadata('echo_report_reopened_with_comment' => $update->id);
$report->unset_extra_metadata('external_status_code');
$report->state('confirmed');
$report->resend;
$report->update;
Expand Down
22 changes: 21 additions & 1 deletion t/cobrand/bromley.t
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,20 @@ subtest 'redirecting of reports between backends' => sub {
email => '3045',
);

my $contact = $mech->create_contact_ok(
body_id => $body->id,
category => 'Street issue',
email => 'Conf_irm',
);
FixMyStreet::DB->resultset("ResponseTemplate")->create({
body_id => $body->id,
title => 'Completed',
text => 'Template text',
auto_response => 1,
state => '',
external_status_code => 67,
});

FixMyStreet::override_config {
ALLOWED_COBRANDS => 'bromley',
COBRAND_FEATURES => {
Expand Down Expand Up @@ -856,6 +870,7 @@ subtest 'redirecting of reports between backends' => sub {
external_id => 'waste',
});
$report->state('fixed - council');
$report->set_extra_metadata(external_status_code => 67);
my $comment = $report->add_to_comments({
text => 'comment on closed event',
user => $user,
Expand All @@ -871,6 +886,8 @@ subtest 'redirecting of reports between backends' => sub {

$report->discard_changes;
is $report->get_extra_metadata('open311_category_override'), 'Referred to Veolia Streets', 'category override applied';
is $report->get_extra_metadata('external_status_code'), undef;
is $report->state, 'confirmed';
is $report->send_state, 'unprocessed', 'report set to be resent';

$comment->discard_changes;
Expand All @@ -896,11 +913,14 @@ subtest 'redirecting of reports between backends' => sub {

subtest "Another update from Echo on this new sent report closes it again" => sub {
$report->update({ external_id => 'guid' });
my $in = $mech->echo_notify_xml('guid', 2104, 15004, '');
my $in = $mech->echo_notify_xml('guid', 2104, 15004, 67);
$mech->post('/waste/echo', Content_Type => 'text/xml', Content => $in);
is $report->comments->count, 3, 'A new update';
$report->discard_changes;
is $report->state, 'fixed - council', 'A state change';
is $report->get_extra_metadata('external_status_code'), 67;
my $comment = FixMyStreet::DB->resultset("Comment")->search(undef, { order_by => { -desc => 'id' } })->first;
is $comment->text, 'Template text';
};
};
};
Expand Down

0 comments on commit bdc15c0

Please sign in to comment.