From 7305e916a9da3a72c8a4e9675d9bdcab6a4bc551 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Mon, 12 Mar 2018 15:27:01 +0000 Subject: [Warwickshire] Add archive script data. Add an update with each report closure. --- t/app/script/archive_old_enquiries.t | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 't/app/script/archive_old_enquiries.t') diff --git a/t/app/script/archive_old_enquiries.t b/t/app/script/archive_old_enquiries.t index e1adeec85..0475cb9ea 100644 --- a/t/app/script/archive_old_enquiries.t +++ b/t/app/script/archive_old_enquiries.t @@ -5,15 +5,18 @@ my $mech = FixMyStreet::TestMech->new(); $mech->clear_emails_ok; -my $opts = { - commit => 1, -}; - my $user = $mech->create_user_ok('test@example.com', name => 'Test User'); my $oxfordshire = $mech->create_body_ok(2237, 'Oxfordshire County Council'); my $west_oxon = $mech->create_body_ok(2420, 'West Oxfordshire District Council'); -$opts->{body} = $oxfordshire->id; +my $opts = { + commit => 1, + body => $oxfordshire->id, + cobrand => 'oxfordshire', + closure_cutoff => "2015-01-01 00:00:00", + email_cutoff => "2016-01-01 00:00:00", + user => $user->id, +}; subtest 'sets reports to the correct status' => sub { FixMyStreet::override_config { @@ -65,6 +68,9 @@ subtest 'sets reports to the correct status' => sub { is $report4->state, 'closed', 'Report 4 has been set to closed'; is $report5->state, 'closed', 'Report 5 has been set to closed'; + my $comment = $report1->comments->first; + is $comment->problem_state, 'closed'; + is $report->state, 'confirmed', 'Recent report has been left alone'; }; }; -- cgit v1.2.3 From b3ca23bc1f8181c2dbd4aa76ae6ed207caa377d7 Mon Sep 17 00:00:00 2001 From: Dave Arter Date: Thu, 12 Apr 2018 14:17:08 +0100 Subject: =?UTF-8?q?Don=E2=80=99t=20send=20alert=20emails=20when=20archivin?= =?UTF-8?q?g=20old=20reports?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- t/app/script/archive_old_enquiries.t | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 't/app/script/archive_old_enquiries.t') 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' ], -- cgit v1.2.3