aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorM Somerville <matthew-github@dracos.co.uk>2020-08-17 13:03:25 +0100
committerM Somerville <matthew-github@dracos.co.uk>2020-08-17 13:14:10 +0100
commit32dadd9c34796a414baf2f8640e03d5ac6a8c0a1 (patch)
tree3e7cdd0f4067747313daa7e56e36d1cd31ac7251
parent65b65bdaef720d2c34aa0377a6e8befd64cdc7e0 (diff)
[Bromley] Fix bug creating response template.
-rw-r--r--perllib/FixMyStreet/Cobrand/Bromley.pm2
-rw-r--r--t/cobrand/bromley.t1
2 files changed, 3 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm
index 859484a4a..4b4363ee3 100644
--- a/perllib/FixMyStreet/Cobrand/Bromley.pm
+++ b/perllib/FixMyStreet/Cobrand/Bromley.pm
@@ -326,6 +326,8 @@ sub add_admin_subcategories {
my $c = $self->{c};
my $user = $c->stash->{user};
+ return unless $user; # e.g. admin templates, not user
+
my @subcategories = @{$user->get_extra_metadata('subcategories') || []};
my %active_contacts = map { $_ => 1 } @subcategories;
diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t
index 71180cd3e..6a7a60811 100644
--- a/t/cobrand/bromley.t
+++ b/t/cobrand/bromley.t
@@ -220,6 +220,7 @@ subtest 'check special subcategories in admin' => sub {
ALLOWED_COBRANDS => 'bromley',
MAPIT_URL => 'http://mapit.uk/',
}, sub {
+ $mech->get_ok('/admin/templates/' . $body->id . '/new');
$mech->get_ok('/admin/users/' . $user->id);
$mech->submit_form_ok({ with_fields => { 'contacts['.$contact->id.']' => 1, 'contacts[BLUE]' => 1 } });
};