Skip to content

Commit a3ae305

Browse files
committed
[Bristol][Alloy] Change grep on category code to be an exact match
A grep of the category code should be an exact match and not regexp to prevent conflict with regexp characters - and better form as should be an exact match anyway.
1 parent 8cda6ae commit a3ae305

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

perllib/Open311/Endpoint/Integration/UK/Bristol/Alloy.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ sub process_attributes {
3333

3434
my $attributes_values = $self->config->{'request_attribute_to_values'};
3535
my $code = $args->{service_code_alloy};
36-
if (grep { $code =~ /$_/ } keys %{
36+
if (grep { $code eq $_ } keys %{
3737
{
3838
%{$self->config->{service_whitelist}->{'SC-Street Cleansing'} || {} },
3939
%{$self->config->{service_whitelist}->{'Abandoned bikes/scooters'} || {} }

t/open311/endpoint/bristol_alloy.t

+29-2
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,19 @@ subtest "check service group and category aliases" => sub {
164164
'service_code' => 'Dog_fouling',
165165
'keywords' => '',
166166
'description' => 'Dog fouling'
167-
}
168-
];
167+
},
168+
{
169+
"type" => "realtime",
170+
"metadata" => "true",
171+
"service_name" => "Glass (broken or not)",
172+
"groups" => [
173+
"Street cleansing"
174+
],
175+
"keywords" => "",
176+
"service_code" => "Glass_(broken_or_not)",
177+
"description" => "Glass (broken or not)"
178+
},
179+
]
169180
};
170181

171182
my %shared_params = (
@@ -319,6 +330,22 @@ for my $test (
319330
},
320331
expected_design => 'designs_bWCSCStreetCleansingDefect_5e21a98bca315003e0983035',
321332
},
333+
{
334+
title => "Glass (broken or not) report",
335+
extra_params => {
336+
'attribute[SizeOfIssue]' => '1',
337+
'attribute[category]' => 'Glass (broken or not)',
338+
'service_code' => 'Glass_(broken_or_not)',
339+
},
340+
expected => {
341+
'attributes_bWCSCStreetCleansingDefectSizeOfIssue_5e21b5ccca31500d1c836be0' => ['5e1f1bf0ca31500c541f82cb'],
342+
'attributes_bWCSCStreetCleansingDefectJobType_5e21b5adca31500d1c836bc9' => ['5e2179a3ca315012d022222'],
343+
'attributes_bWCSCStreetCleansingDefectFullDetails_5e21b587ca31500cc0a2df3a' => "title\n\ndescription",
344+
'attributes_bWCSCStreetCleansingDefectLocality_5e6f97fe4cee260f90aca0d6' => ['5e16fa66ca314f0980300be5'],
345+
'attributes_bWCSCStreetCleansingDefectFixMyStreetID_67654e2a1e4316383b73050f' => '123',
346+
},
347+
expected_design => 'designs_bWCSCStreetCleansingDefect_5e21a98bca315003e0983035',
348+
},
322349
) {
323350
subtest $test->{title} => sub {
324351
my $res = $endpoint->run_test_request(

t/open311/endpoint/bristol_alloy.yml

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"Blood": 1,
2525
"Dead animal": 1,
2626
"Dog fouling": 1,
27+
"Glass (broken or not)": 1,
2728
},
2829
},
2930

@@ -90,6 +91,7 @@
9091
'Blood': '5e21782dca315003e09804a2',
9192
'Dog fouling': '5e2179a3ca315012d0956667',
9293
'Abandoned private bike/scooter': '5e2179a3ca315012d099999',
94+
'Glass (broken or not)': '5e2179a3ca315012d022222'
9395
},
9496
},
9597

0 commit comments

Comments
 (0)