From 4fd8fce72cf9adae08e1827fda984049a10580a5 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 17 May 2018 17:59:35 +0100 Subject: [Bromley] Include asset ID in title if given. --- perllib/FixMyStreet/Cobrand/Bromley.pm | 10 +++++++++- t/cobrand/bromley.t | 12 +++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm index 2f47225a7..95ed5dc12 100644 --- a/perllib/FixMyStreet/Cobrand/Bromley.pm +++ b/perllib/FixMyStreet/Cobrand/Bromley.pm @@ -112,11 +112,19 @@ sub open311_config { my ($self, $row, $h, $params) = @_; my $extra = $row->get_extra_fields; + my $title = $row->title; + + foreach (@$extra) { + $title .= ' | ID: ' . $_->{value} if $_->{name} eq 'feature_id'; + $title .= ' | PROW ID: ' . $_->{value} if $_->{name} eq 'prow_reference'; + } + @$extra = grep { $_->{name} !~ /feature_id|prow_reference/ } @$extra; + push @$extra, { name => 'report_url', value => $h->{url} }, { name => 'report_title', - value => $row->title }, + value => $title }, { name => 'public_anonymity_required', value => $row->anonymous ? 'TRUE' : 'FALSE' }, { name => 'email_alerts_requested', diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t index e42ab5be2..b3fb3564b 100644 --- a/t/cobrand/bromley.t +++ b/t/cobrand/bromley.t @@ -54,6 +54,7 @@ for my $test ( 'attribute[easting]' => 529025, 'attribute[northing]' => 179716, 'attribute[service_request_id_ext]' => $report->id, + 'attribute[report_title]' => 'Test Test 1 for ' . $body->id, 'jurisdiction_id' => 'FMS', address_id => undef, }, @@ -72,11 +73,20 @@ for my $test ( 'address_id' => '#NOTPINPOINTED#', }, }, + { + desc => 'asset ID', + feature_id => '1234', + expected => { + 'attribute[service_request_id_ext]' => $report->id, + 'attribute[report_title]' => 'Test Test 1 for ' . $body->id . ' | ID: 1234', + }, + }, ) { subtest $test->{desc}, sub { - $report->set_extra_fields(); $report->$_($test->{updates}->{$_}) for keys %{$test->{updates}}; $report->$_(undef) for qw/ whensent send_method_used external_id /; + $report->set_extra_fields({ name => 'feature_id', value => $test->{feature_id} }) + if $test->{feature_id}; $report->update; $body->update( { send_method => 'Open311', endpoint => 'http://bromley.endpoint.example.com', jurisdiction => 'FMS', api_key => 'test', send_comments => 1 } ); my $test_data; -- cgit v1.2.3