aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2018-05-17 17:55:05 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-06-04 14:09:31 +0100
commit360539076792ddaea6cb1ffb5cd48d694fc75be6 (patch)
treeecfe4581b8a0376e70ea0b4405325bfaa5028317
parent46655c327dc3a3d1d16b685f11c58dad1f632db4 (diff)
[Bromley] Add asset/PROW ID meta to attributes.
-rw-r--r--perllib/Open311/PopulateServiceList.pm19
-rw-r--r--t/open311/populate-service-list.t72
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 = '<?xml version="1.0" encoding="utf-8"?>
-<service_definition>
- <service_code>100</service_code>
- <attributes>
- <attribute>
- <variable>true</variable>
- <code>type</code>
- <datatype>string</datatype>
- <required>true</required>
- <datatype_description>Type of bin</datatype_description>
- <order>1</order>
- <description>Type of bin</description>
- </attribute>
- </attributes>
-</service_definition>
- ';
-
- 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 = '<?xml version="1.0" encoding="utf-8"?>
@@ -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;