diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-05-14 15:25:20 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-05-23 18:55:10 +0100 |
commit | df731c5a0ffccc434550ca4dd2ecace5287848fa (patch) | |
tree | 2d5c2bd50830c68b7f925520802ea06bcb7f6235 /t/script | |
parent | e663d5e373dfafedd4be7e6e79ac79eae511b54d (diff) |
Script to email/anonymize inactive users.
Diffstat (limited to 't/script')
-rw-r--r-- | t/script/inactive.t | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/t/script/inactive.t b/t/script/inactive.t new file mode 100644 index 000000000..0eaeea2ad --- /dev/null +++ b/t/script/inactive.t @@ -0,0 +1,28 @@ +use FixMyStreet::TestMech; + +use_ok 'FixMyStreet::Script::Inactive'; + +my $in = FixMyStreet::Script::Inactive->new( anonymize => 6, email => 3 ); +my $mech = FixMyStreet::TestMech->new; + +my $user = FixMyStreet::DB->resultset("User")->find_or_create({ email => 'test@example.com' }); +my $t = DateTime->new(year => 2016, month => 1, day => 1, hour => 12); +$user->last_active($t); +$user->update; + +my $user_inactive = FixMyStreet::DB->resultset("User")->find_or_create({ email => 'inactive@example.com' }); +$t = DateTime->now->subtract(months => 4); +$user_inactive->last_active($t); +$user_inactive->update; + +subtest 'Anonymization of inactive users' => sub { + $in->users; + + my $email = $mech->get_email; + like $email->as_string, qr/inactive\@example.com/, 'Inactive email sent'; + + $user->discard_changes; + is $user->email, 'removed-' . $user->id . '@example.org', 'User has been anonymized'; +}; + +done_testing; |