From bdc15c07da0ab33f485e9384cb0362d02c642a26 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Fri, 7 Jun 2024 12:48:52 +0100 Subject: [PATCH] [Bromley] Unset external status code when reopening Echo report. 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. --- perllib/FixMyStreet/Cobrand/Bromley.pm | 1 + t/cobrand/bromley.t | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm index 5c0b6f6ff7f..d4ea8d9291e 100644 --- a/perllib/FixMyStreet/Cobrand/Bromley.pm +++ b/perllib/FixMyStreet/Cobrand/Bromley.pm @@ -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; diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t index 0f4c5538f02..5ce4da52374 100644 --- a/t/cobrand/bromley.t +++ b/t/cobrand/bromley.t @@ -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 => { @@ -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, @@ -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; @@ -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'; }; }; };