diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-02-07 13:09:04 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-02-07 13:09:04 +0000 |
commit | 6879af98d0246b6973affff08a4e078206bb5dfc (patch) | |
tree | 73dbc53ea15e1e3324cf9843ccf39bc2cdc23b95 /t | |
parent | 1e301bf1e07daf35150d54b132bbbe66f0a8095e (diff) | |
parent | d126f95249a0a7b0b0c3289b597a7b89e13a2fbb (diff) |
Merge branch '1944-admin-remove-account'
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/admin/users.t | 26 | ||||
-rw-r--r-- | t/app/controller/report_new.t | 8 |
2 files changed, 28 insertions, 6 deletions
diff --git a/t/app/controller/admin/users.t b/t/app/controller/admin/users.t index e6cf51449..63295e26d 100644 --- a/t/app/controller/admin/users.t +++ b/t/app/controller/admin/users.t @@ -410,4 +410,30 @@ subtest "Hiding user's reports from admin" => sub { is $c, $count_u; }; +subtest "Logging user out" => sub { + my $mech2 = FixMyStreet::TestMech->new; + $mech2->log_in_ok($user->email); + $mech2->logged_in_ok; + + $mech->get_ok( '/admin/user_edit/' . $user->id ); + $mech->submit_form_ok({ button => 'logout_everywhere' }, 'Logging user out'); + $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(); diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t index e0fe205bd..95461fa8f 100644 --- a/t/app/controller/report_new.t +++ b/t/app/controller/report_new.t @@ -1236,9 +1236,7 @@ for my $test ( is $user->title, $test->{'user_title'}, 'user title correct'; is_deeply $extras, $test->{extra}, 'extra contains correct values'; - $user->problems->delete; - $user->alerts->delete; - $user->delete; + $mech->delete_user($user); }; } @@ -1705,9 +1703,7 @@ subtest "extra google analytics code displayed on email confirmation problem cre $mech->content_contains( "'id': 'report/" . $report->id . "'", 'extra google code present' ); - $user->problems->delete; - $user->alerts->delete; - $user->delete; + $mech->delete_user($user); }; }; |