aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2018-04-12 14:17:08 +0100
committerDave Arter <davea@mysociety.org>2018-04-12 14:31:19 +0100
commitb3ca23bc1f8181c2dbd4aa76ae6ed207caa377d7 (patch)
tree5db778772894ffcb3575217e22a4e5d87f8ae54e /t
parent9fde903b6f9d2fa70e666cd5d9f864cb275bffe2 (diff)
Don’t send alert emails when archiving old reports
Diffstat (limited to 't')
-rw-r--r--t/app/script/archive_old_enquiries.t35
1 files changed, 35 insertions, 0 deletions
diff --git a/t/app/script/archive_old_enquiries.t b/t/app/script/archive_old_enquiries.t
index 0475cb9ea..9774d3fc3 100644
--- a/t/app/script/archive_old_enquiries.t
+++ b/t/app/script/archive_old_enquiries.t
@@ -75,6 +75,41 @@ subtest 'sets reports to the correct status' => sub {
};
};
+subtest 'marks alerts as sent' => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'oxfordshire' ],
+ }, sub {
+ my ($report) = $mech->create_problems_for_body(1, $oxfordshire->id, 'Test', {
+ areas => ',2237,',
+ lastupdate => '2015-12-01 07:00:00',
+ user_id => $user->id,
+ });
+ my $alert = FixMyStreet::DB->resultset('Alert')->find_or_create(
+ {
+ user => $user,
+ parameter => $report->id,
+ alert_type => 'new_updates',
+ whensubscribed => '2015-12-01 07:00:00',
+ confirmed => 1,
+ cobrand => 'default',
+ }
+ );
+ is $alert->alerts_sent->count, 0, 'Nothing has been sent for this alert';
+
+ FixMyStreet::Script::ArchiveOldEnquiries::archive($opts);
+
+ $report->discard_changes;
+
+ is $report->state, 'closed', 'Report has been set to closed';
+
+ is $alert->alerts_sent->count, 1, 'Alert marked as sent for this report';
+
+ my $alert_sent = $alert->alerts_sent->first;
+ my $comment = $report->comments->first;
+ is $alert_sent->parameter, $comment->id, 'AlertSent created for new comment';
+ };
+};
+
subtest 'sends emails to a user' => sub {
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'oxfordshire' ],