aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin/Templates.pm2
-rw-r--r--t/app/controller/admin/templates.t45
2 files changed, 47 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin/Templates.pm b/perllib/FixMyStreet/App/Controller/Admin/Templates.pm
index 97a62c2b8..efff1b488 100644
--- a/perllib/FixMyStreet/App/Controller/Admin/Templates.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin/Templates.pm
@@ -69,8 +69,10 @@ sub edit : Path : Args(2) {
category => $_->category_display,
active => $active_contacts{$_->id},
email => $_->email,
+ group => $_->get_extra_metadata('group') // '',
} } @live_contacts;
$c->stash->{contacts} = \@all_contacts;
+ $c->forward('/report/stash_category_groups', [ \@all_contacts, 1 ]) if $c->cobrand->enable_category_groups;
# bare block to use 'last' if form is invalid.
if ($c->req->method eq 'POST') { {
diff --git a/t/app/controller/admin/templates.t b/t/app/controller/admin/templates.t
index ca1cba46d..ac915af94 100644
--- a/t/app/controller/admin/templates.t
+++ b/t/app/controller/admin/templates.t
@@ -8,6 +8,7 @@ my $superuser = $mech->create_user_ok('superuser@example.com', name => 'Super Us
my $oxfordshire = $mech->create_body_ok(2237, 'Oxfordshire County Council');
my $oxfordshirecontact = $mech->create_contact_ok( body_id => $oxfordshire->id, category => 'Potholes', email => 'potholes@example.com' );
+my $oxfordshirecontact2 = $mech->create_contact_ok( body_id => $oxfordshire->id, category => 'Flytipping', email => 'flytipping@example.com' );
my $oxfordshireuser = $mech->create_user_ok('counciluser@example.com', name => 'Council User', from_body => $oxfordshire);
my $bromley = $mech->create_body_ok(2482, 'Bromley Borough Council');
@@ -282,6 +283,50 @@ subtest "templates that set state and external_status_code can't be added" => su
is $oxfordshire->response_templates->count, 0, "Invalid response template wasn't added";
};
+subtest "category groups are shown" => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'oxfordshire' ],
+ COBRAND_FEATURES => {
+ category_groups => {
+ oxfordshire => 1,
+ },
+ multiple_category_groups => {
+ oxfordshire => 1,
+ },
+ },
+ }, sub {
+
+ $mech->log_in_ok( $superuser->email );
+
+ $mech->get_ok( "/admin/templates/" . $oxfordshire->id . "/new" );
+ $mech->content_contains("No Group") or diag $mech->content;
+ $mech->content_lacks("Multiple Groups");
+ $mech->content_lacks("These categories appear in more than one group:");
+
+ $oxfordshirecontact->set_extra_metadata( group => [ 'Highways' ] );
+ $oxfordshirecontact->update;
+ $oxfordshirecontact2->set_extra_metadata( group => [ 'Street Cleaning' ] );
+ $oxfordshirecontact2->update;
+ $mech->get_ok( "/admin/templates/" . $oxfordshire->id . "/new" );
+ $mech->content_lacks("No Group");
+ $mech->content_lacks("Multiple Groups");
+ $mech->content_lacks("These categories appear in more than one group:");
+ $mech->content_contains("Highways");
+ $mech->content_contains("Street Cleaning");
+
+ $oxfordshirecontact->set_extra_metadata( group => [ 'Highways', 'Roads & Pavements' ] );
+ $oxfordshirecontact->update;
+ $oxfordshirecontact2->set_extra_metadata( group => [ 'Street Cleaning' ] );
+ $oxfordshirecontact2->update;
+ $mech->get_ok( "/admin/templates/" . $oxfordshire->id . "/new" );
+ $mech->content_lacks("No Group");
+ $mech->content_contains("Multiple Groups");
+ $mech->content_contains("These categories appear in more than one group:");
+ $mech->content_contains("Highways; Roads & Pavements");
+ $mech->content_contains("Street Cleaning");
+ };
+};
+
subtest "TfL cobrand only shows TfL templates" => sub {
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'tfl' ],