diff options
author | Dave Arter <davea@mysociety.org> | 2016-12-06 11:57:34 +0000 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2016-12-06 12:16:22 +0000 |
commit | 102418842a833c29f855557bf4c410290b5a2020 (patch) | |
tree | d639ff3adbd2fecadfd5ac1266cccf65db093f47 /t/cobrand | |
parent | 7df5f6d00c34580987509a2ccb4520d2fde96866 (diff) |
[Zurich] Fix 500 error when editing superusers
The Zurich::admin_type function was setting $c->stash->{body}, meaning that
when trying to edit a superuser the 'fetch_contacts' function wasn't being
called, causing an "Can't call method "all" on an undefined value" error as
$c->stash->{live_contacts} wasn't ever being set.
Fixed by changing the conditional to simply determine whether fetch_contacts
needs to be called.
Included a regression test that meant a small addition to the MapItZurich mock.
Diffstat (limited to 't/cobrand')
-rw-r--r-- | t/cobrand/zurich.t | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t index b59e546dd..ddaae1f90 100644 --- a/t/cobrand/zurich.t +++ b/t/cobrand/zurich.t @@ -102,8 +102,9 @@ sub get_export_rows_count { my $EXISTING_REPORT_COUNT = 0; +my $superuser; subtest "set up superuser" => sub { - my $superuser = $mech->log_in_ok( 'super@example.org' ); + $superuser = $mech->log_in_ok( 'super@example.org' ); # a user from body $zurich is a superuser, as $zurich has no parent id! $superuser->update({ from_body => $zurich->id }); $EXISTING_REPORT_COUNT = get_export_rows_count($mech); @@ -968,6 +969,18 @@ subtest 'time_spent' => sub { $mech->log_out_ok; +FixMyStreet::override_config { + ALLOWED_COBRANDS => [ 'zurich' ], + MAPIT_URL => 'http://mapit.zurich/', + MAPIT_TYPES => [ 'ZZZ' ], +}, sub { + LWP::Protocol::PSGI->register(t::Mock::MapItZurich->run_if_script, host => 'mapit.zurich'); + subtest 'users at the top level can be edited' => sub { + $mech->log_in_ok( $superuser->email ); + $mech->get_ok('/admin/user_edit/' . $superuser->id ); + }; +}; + END { $mech->delete_body($subdivision); $mech->delete_body($division); |