diff options
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 6 | ||||
-rw-r--r-- | t/app/controller/report_new.t | 3 |
2 files changed, 6 insertions, 3 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index eb7934da3..7c7ebd202 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -744,8 +744,10 @@ sub setup_categories_and_bodies : Private { if ( $c->cobrand->enable_category_groups ) { my %category_groups = (); for my $category (@category_options) { - my $group = $category->{group} // $category->get_extra_metadata('group') // ''; - push @{$category_groups{$group}}, $category; + my $group = $category->{group} // $category->get_extra_metadata('group') // ['']; + # this could be an array ref or a string + my @groups = ref $group eq 'ARRAY' ? @$group : ($group); + push( @{$category_groups{$_}}, $category ) for @groups; } my @category_groups = (); diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t index d6b256be1..f65ca243d 100644 --- a/t/app/controller/report_new.t +++ b/t/app/controller/report_new.t @@ -1278,10 +1278,11 @@ subtest "category groups" => sub { category_groups => { fixmystreet => 1 } } }, sub { - $contact2->update( { extra => { group => 'Roads' } } ); + $contact2->update( { extra => { group => ['Roads','Pavements'] } } ); $contact9->update( { extra => { group => 'Roads' } } ); $contact10->update( { extra => { group => 'Roads' } } ); $mech->get_ok("/report/new?lat=$saved_lat&lon=$saved_lon"); + $mech->content_like(qr{<optgroup label="Pavements">\s*<option value='Potholes'>Potholes</option></optgroup>}); $mech->content_like(qr{<optgroup label="Roads">\s*<option value='Potholes'>Potholes</option>\s*<option value='Street lighting'>Street lighting</option></optgroup>}); }; }; |