From 360539076792ddaea6cb1ffb5cd48d694fc75be6 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 17 May 2018 17:55:05 +0100 Subject: [Bromley] Add asset/PROW ID meta to attributes. --- perllib/Open311/PopulateServiceList.pm | 19 +++++++++ t/open311/populate-service-list.t | 72 +++++----------------------------- 2 files changed, 28 insertions(+), 63 deletions(-) diff --git a/perllib/Open311/PopulateServiceList.pm b/perllib/Open311/PopulateServiceList.pm index d283beb0f..4ffd8c143 100644 --- a/perllib/Open311/PopulateServiceList.pm +++ b/perllib/Open311/PopulateServiceList.pm @@ -248,6 +248,25 @@ sub _add_meta_to_contact_cobrand_overrides { if ($self->_current_body->name eq 'Bromley Council') { $contact->set_extra_metadata( id_field => 'service_request_id_ext'); + # Lights we want to store feature ID, PROW on all categories. + push @$meta, { + code => 'prow_reference', + datatype => 'string', + description => 'Right of way reference', + order => 101, + required => 'false', + variable => 'true', + automated => 'hidden_field', + }; + push @$meta, { + code => 'feature_id', + datatype => 'string', + description => 'Feature ID', + order => 100, + required => 'false', + variable => 'true', + automated => 'hidden_field', + } if $self->_current_service->{service_code} eq 'LIGHTS'; } elsif ($self->_current_body->name eq 'Warwickshire County Council') { $contact->set_extra_metadata( id_field => 'external_id'); } diff --git a/t/open311/populate-service-list.t b/t/open311/populate-service-list.t index 7d4f491c6..b54b1c242 100644 --- a/t/open311/populate-service-list.t +++ b/t/open311/populate-service-list.t @@ -192,67 +192,6 @@ subtest 'check conflicting contacts not changed' => sub { is $contact_count, 4, 'correct number of contacts'; }; -subtest 'check meta data population' => sub { - my $processor = Open311::PopulateServiceList->new(); - - my $meta_xml = ' - - 100 - - - true - type - string - true - Type of bin - 1 - Type of bin - - - - '; - - my $contact = FixMyStreet::DB->resultset('Contact')->find_or_create( - { - body_id => 1, - email => '001', - category => 'Bins left out 24x7', - state => 'confirmed', - editor => $0, - whenedited => \'current_timestamp', - note => 'test contact', - } - ); - - my $o = Open311->new( - jurisdiction => 'mysociety', - endpoint => 'http://example.com', - test_mode => 1, - test_get_returns => { 'services/100.xml' => $meta_xml } - ); - - $processor->_current_open311( $o ); - $processor->_current_body( $bromley ); - $processor->_current_service( { service_code => 100 } ); - - $processor->_add_meta_to_contact( $contact ); - - my $extra = [ { - variable => 'true', - code => 'type', - datatype => 'string', - required => 'true', - datatype_description => 'Type of bin', - order => 1, - description => 'Type of bin' - - } ]; - - $contact->discard_changes; - - is_deeply $contact->get_extra_fields, $extra, 'meta data saved'; -}; - for my $test ( { desc => 'check meta data added to existing contact', @@ -527,7 +466,7 @@ subtest 'check attribute ordering' => sub { is_deeply $contact->get_extra_fields, $extra, 'meta data re-ordered correctly'; }; -subtest 'check bromely skip code' => sub { +subtest 'check Bromley skip code' => sub { my $processor = Open311::PopulateServiceList->new(); my $meta_xml = ' @@ -598,7 +537,14 @@ subtest 'check bromely skip code' => sub { datatype_description => 'Type of bin', order => 1, description => 'Type of bin' - + }, { + automated => 'hidden_field', + variable => 'true', + code => 'prow_reference', + datatype => 'string', + required => 'false', + order => 101, + description => 'Right of way reference' } ]; $contact->discard_changes; -- cgit v1.2.3