From d126f95249a0a7b0b0c3289b597a7b89e13a2fbb Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Wed, 31 Jan 2018 16:15:44 +0000 Subject: Admin ability to remove user account details. --- t/app/controller/admin/users.t | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 't/app/controller/admin') diff --git a/t/app/controller/admin/users.t b/t/app/controller/admin/users.t index 187652b3c..63295e26d 100644 --- a/t/app/controller/admin/users.t +++ b/t/app/controller/admin/users.t @@ -420,4 +420,20 @@ subtest "Logging user out" => sub { $mech2->not_logged_in_ok; }; +subtest "Removing account from admin" => sub { + $mech->create_problems_for_body(4, 2237, 'Title'); + my $count_p = FixMyStreet::DB->resultset('Problem')->search({ user_id => $user->id })->count; + my $count_u = FixMyStreet::DB->resultset('Comment')->search({ user_id => $user->id })->count; + $mech->get_ok( '/admin/user_edit/' . $user->id ); + $mech->submit_form_ok({ button => 'remove_account' }, 'Removing account'); + my $c = FixMyStreet::DB->resultset('Problem')->search({ user_id => $user->id, anonymous => 1, name => '' })->count; + is $c, $count_p, 'All reports anon/nameless'; + $c = FixMyStreet::DB->resultset('Comment')->search({ user_id => $user->id, anonymous => 1, name => '' })->count; + is $c, $count_u, 'All updates anon/nameless'; + $user->discard_changes; + is $user->name, '', 'Name gone'; + is $user->password, '', 'Password gone'; + is $user->email, 'removed-' . $user->id . '@example.org', 'Email gone' +}; + done_testing(); -- cgit v1.2.3