diff options
author | Struan Donald <struan@exo.org.uk> | 2012-11-23 13:17:53 +0000 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2012-11-23 13:17:53 +0000 |
commit | abed59f3f16cc15826cebcb17a243822d7a397b1 (patch) | |
tree | 65dc1421294ff67e60310e5336fec86ef1278c5f | |
parent | 967e470fd58fb044fdd7c47315416c24030546b3 (diff) |
do not fall over if there is unexpectedly no meta data for a service code
-rw-r--r-- | perllib/Open311/PopulateServiceList.pm | 8 | ||||
-rw-r--r-- | t/open311/populate-service-list.t | 13 |
2 files changed, 21 insertions, 0 deletions
diff --git a/perllib/Open311/PopulateServiceList.pm b/perllib/Open311/PopulateServiceList.pm index d8730a703..e8ae56833 100644 --- a/perllib/Open311/PopulateServiceList.pm +++ b/perllib/Open311/PopulateServiceList.pm @@ -207,6 +207,14 @@ sub _add_meta_to_contact { ]; } + if ( ! $meta_data->{attributes}->{attribute} ) { + warn sprintf( "Empty meta data for %s at %s", + $self->_current_service->{service_code}, + $self->_current_council->endpoint ) + if $self->verbose; + return; + } + # turn the data into something a bit more friendly to use my @meta = # remove trailing colon as we add this when we display so we don't want 2 diff --git a/t/open311/populate-service-list.t b/t/open311/populate-service-list.t index 5910a8f13..00026cd9f 100644 --- a/t/open311/populate-service-list.t +++ b/t/open311/populate-service-list.t @@ -372,6 +372,19 @@ for my $test ( </service_definition> ', }, + { + desc => 'check empty meta data handled', + has_meta => 1, + orig_meta => undef, + end_meta => undef, + meta_xml => '<?xml version="1.0" encoding="utf-8"?> + <service_definition> + <service_code>100</service_code> + <attributes> + </attributes> + </service_definition> + ', + }, ) { subtest $test->{desc} => sub { my $processor = Open311::PopulateServiceList->new( council_list => [] ); |