Skip to content

Commit

Permalink
[Bromley] hide referrral update after sending, no prefix.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Sep 24, 2024
1 parent 139b75e commit a98b4e0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
24 changes: 13 additions & 11 deletions perllib/FixMyStreet/Cobrand/Bromley.pm
Original file line number Diff line number Diff line change
Expand Up @@ -334,26 +334,28 @@ sub _include_user_title_in_extra {
sub open311_pre_send_updates {
my ($self, $row) = @_;

$self->{bromley_original_update_text} = $row->text;

my $private_comments = $row->get_extra_metadata('private_comments');
if ($private_comments) {
my $text = $row->text . "\n\nPrivate comments: $private_comments";
$row->text($text);
}

return $self->_include_user_title_in_extra($row);
}

sub open311_post_send_updates {
my ($self, $row) = @_;
my ($self, $comment, $external_id) = @_;

$row->text($self->{bromley_original_update_text});
if (($comment->problem_state || '') eq REFERRED_TO_BROMLEY) {
if ($external_id) {
$comment->state('hidden');

Check warning on line 345 in perllib/FixMyStreet/Cobrand/Bromley.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bromley.pm#L345

Added line #L345 was not covered by tests
}
}
}

sub open311_munge_update_params {
my ($self, $params, $comment, $body) = @_;

my $private_comments = $comment->get_extra_metadata('private_comments');
if ($private_comments) {
my $text = $params->{description} . "\n\nPrivate comments: $private_comments";
$params->{description} = $text;
}

delete $params->{update_id};
$params->{public_anonymity_required} = $comment->anonymous ? 'TRUE' : 'FALSE',
$params->{update_id_ext} = $comment->id;
Expand All @@ -362,7 +364,7 @@ sub open311_munge_update_params {
if (($comment->problem_state || '') eq REFERRED_TO_BROMLEY) {
$params->{status} = 'REFERRED_TO_LBB_STREETS';
if (my $handover_notes = $comment->problem->get_extra_metadata('handover_notes')) {
$params->{description} .= " | Handover notes - $handover_notes";
$params->{description} = $handover_notes;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion perllib/Open311/PostServiceRequestUpdates.pm
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ sub process_update {

my $id = $o->post_service_request_update( $comment );

$cobrand->call_hook(open311_post_send_updates => $comment);
$cobrand->call_hook(open311_post_send_updates => $comment, $id);

if ( $id ) {
$comment->update( {
Expand Down
7 changes: 6 additions & 1 deletion t/cobrand/bromley.t
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,7 @@ subtest 'redirecting of reports between backends' => sub {
$update->process_body;
$report->discard_changes;
is $report->comments->count, 1;
is_deeply [ map { $_->state } $report->comments->all ], ['hidden'];
is $report->whensent, undef;
is $report->get_extra_metadata('handover_notes'), 'This is a handover note';
is $report->category, 'Referred to Veolia Streets';
Expand All @@ -817,6 +818,7 @@ subtest 'redirecting of reports between backends' => sub {
$report->update({ external_id => 'parent-guid', whensent => DateTime->now, send_method_used => 'Open311' });
$mech->post('/waste/echo', Content_Type => 'text/xml', Content => $in);
is $report->comments->count, 2, 'A new update';
is_deeply [ map { $_->state } $report->comments->order_by('id')->all ], ['hidden', 'confirmed'];
$report->discard_changes;
is $report->external_id, 12345, 'ID changed back';
is $report->state, 'in progress', 'A state change';
Expand All @@ -832,14 +834,17 @@ subtest 'redirecting of reports between backends' => sub {
my $c = CGI::Simple->new($req->content);
is $c->param('status'), 'REFERRED_TO_LBB_STREETS';
is $c->param('service_code'), 'LBB_RRE_FROM_VEOLIA_STREETS';
is $c->param('description'), "Completed | Handover notes - Outgoing notes from Echo";
is $c->param('description'), "Outgoing notes from Echo";

is_deeply [ map { $_->state } $report->comments->order_by('id')->all ], ['hidden', 'hidden'];
};
subtest 'A report sent to Echo, redirected to Confirm' => sub {
$report->comments->delete;
$report->unset_extra_metadata('original_bromley_external_id');
$report->update({ external_id => 'original-guid' });
$mech->post('/waste/echo', Content_Type => 'text/xml', Content => $in);
is $report->comments->count, 1, 'A new update';
is_deeply [ map { $_->state } $report->comments->all ], ['hidden'];
$report->discard_changes;
is $report->whensent, undef;
is $report->external_id, 'original-guid', 'ID not changed';
Expand Down

0 comments on commit a98b4e0

Please sign in to comment.