aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2020-02-26 11:25:37 +0000
committerMatthew Somerville <matthew@mysociety.org>2020-02-26 13:52:14 +0000
commita6b58401b3bef860713f96c1ba5c576bd94e0b10 (patch)
tree51993962226e1de3754f0f1da13c4429f46b8ef5 /t
parent75cf754c0b13b4547d249423c20f3fe9903deb12 (diff)
Fix error hiding user's updates with no confirmed.
If a user had no confirmed updates, but did have e.g. an unconfirmed update that had mark_fixed set, you would get an error when trying to hide the user's reports/updates.
Diffstat (limited to 't')
-rw-r--r--t/app/controller/admin/users.t11
1 files changed, 10 insertions, 1 deletions
diff --git a/t/app/controller/admin/users.t b/t/app/controller/admin/users.t
index 2e3ad9e5a..a36a4187a 100644
--- a/t/app/controller/admin/users.t
+++ b/t/app/controller/admin/users.t
@@ -564,7 +564,10 @@ subtest "Send login email from admin for unverified email" => sub {
};
subtest "Anonymizing user from admin" => sub {
- $mech->create_problems_for_body(4, 2237, 'Title');
+ my ($problem) = $mech->create_problems_for_body(4, 2237, 'Title');
+ $mech->create_comment_for_problem($problem, $user, $user->name, 'An update', 'f', 'confirmed', 'confirmed');
+ $mech->create_comment_for_problem($problem, $user, $user->name, '2nd update', 't', 'confirmed', 'fixed - user');
+ $mech->create_comment_for_problem($problem, $user, $user->name, '3rd update', 'f', 'unconfirmed', 'confirmed');
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/users/' . $user->id );
@@ -586,6 +589,12 @@ subtest "Hiding user's reports from admin" => sub {
is $c, $count_u;
};
+subtest "Hiding user with only unconfirmed updates does not error" => sub {
+ FixMyStreet::DB->resultset('Comment')->search({ user_id => $user->id, state => 'hidden' })->update({ state => 'unconfirmed' });
+ $mech->get_ok( '/admin/users/' . $user->id );
+ $mech->submit_form_ok({ button => 'hide_everywhere' });
+};
+
subtest "Logging user out" => sub {
my $mech2 = FixMyStreet::TestMech->new;
$mech2->log_in_ok($user->email);