aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2020-01-08 16:16:48 +0000
committerMatthew Somerville <matthew@mysociety.org>2020-01-09 17:31:45 +0000
commit4a3b51a366825b42f451f5eeac93b990a602e57e (patch)
treead293c091cf3947cde776e9f9b6fb6e50fe9b832 /t
parent65ca47eda62a45bf081128b507c94c7b18a77a00 (diff)
[TfL] Add hook to restrict to safety reports.
Diffstat (limited to 't')
-rw-r--r--t/script/inactive.t29
1 files changed, 29 insertions, 0 deletions
diff --git a/t/script/inactive.t b/t/script/inactive.t
index 26eab33e1..5ef4073dd 100644
--- a/t/script/inactive.t
+++ b/t/script/inactive.t
@@ -109,4 +109,33 @@ subtest 'Anonymization of inactive users' => sub {
is $user->email, 'removed-' . $user->id . '@example.org', 'User has been anonymized';
};
+subtest 'Test TfL deletion of safety critical reports' => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => 'tfl'
+ }, sub {
+ for (my $y = 2; $y <= 10; $y+=2) {
+ # 2 years, not safety; 4 years safety, 6 years not safety, 8 years safety, 10 years not safety
+ my $t = DateTime->now->subtract(years => $y);
+ my ($problem) = $mech->create_problems_for_body(1, 2237, 'Title', {
+ dt => $t,
+ lastupdate => "$t",
+ state => 'fixed - user',
+ cobrand => 'tfl',
+ });
+ $problem->update_extra_field({ name => 'safety_critical', value => $y % 4 ? 'no' : 'yes' });
+ $problem->update;
+ }
+
+ my $in = FixMyStreet::Script::Inactive->new( cobrand => 'tfl', delete => 36 );
+ $in->reports;
+ my $count = FixMyStreet::DB->resultset("Problem")->search({ cobrand => 'tfl' })->count;
+ is $count, 3, 'Three reports left, one too recent, two safety critical';
+
+ $in = FixMyStreet::Script::Inactive->new( cobrand => 'tfl', delete => 84 );
+ $in->reports;
+ $count = FixMyStreet::DB->resultset("Problem")->search({ cobrand => 'tfl' })->count;
+ is $count, 2, 'Two reports left, two too recent';
+ }
+};
+
done_testing;