diff options
author | Struan Donald <struan@exo.org.uk> | 2013-09-12 15:57:38 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2013-09-12 15:57:38 +0100 |
commit | 64f97d4cf9ad64905006e504f3ffb47fb373eca9 (patch) | |
tree | 243eab3c96714f031069cdf22355e08164a73c03 /t/app/model/problem.t | |
parent | 327407222c53c78e87ad4bcad26c16a00d971a11 (diff) |
Test to check reports from abuse users not sent
Reports that have been created by a user who is logged in but whose
email is in the abuse table should be hidden and not sent by
send_reports.
Diffstat (limited to 't/app/model/problem.t')
-rw-r--r-- | t/app/model/problem.t | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/t/app/model/problem.t b/t/app/model/problem.t index 7daa653fc..5d02aef2b 100644 --- a/t/app/model/problem.t +++ b/t/app/model/problem.t @@ -630,6 +630,53 @@ subtest 'check can turn on report sent email alerts' => sub { like $email->body, qr/Your report about/, 'report sent body correct'; }; +subtest 'check reports from abuser not sent' => sub { + $mech->clear_emails_ok; + + FixMyStreet::App->model('DB::Problem')->search( + { + whensent => undef + } + )->update( { whensent => \'ms_current_timestamp()' } ); + + $problem->discard_changes; + $problem->update( { + title => 'Report', + state => 'confirmed', + confirmed => \'ms_current_timestamp()', + whensent => undef, + category => 'potholes', + send_fail_count => 0, + } ); + + FixMyStreet::App->model('DB::Problem')->send_reports(); + + $mech->email_count_is( 1 ); + + $problem->discard_changes(); + ok $problem->whensent, 'Report has been sent'; + + $problem->update( { + state => 'confirmed', + confirmed => \'ms_current_timestamp()', + whensent => undef, + } ); + + my $abuse = FixMyStreet::App->model('DB::Abuse')->create( { email => $problem->user->email } ); + + $mech->clear_emails_ok; + FixMyStreet::App->model('DB::Problem')->send_reports(); + + $mech->email_count_is( 0 ); + + $problem->discard_changes(); + is $problem->state, 'hidden', 'reports from abuse user are hidden automatically'; + is $problem->whensent, undef, 'reports from abuse user are not sent'; + + ok $abuse->delete(), 'user removed from abuse table'; +}; + + $problem->comments->delete; $problem->delete; $mech->delete_user( $user ); |