aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2019-09-19 12:18:24 +0100
committerStruan Donald <struan@exo.org.uk>2019-09-27 17:43:38 +0100
commit6b01232a4108accdb4bc5f2cbca1044c1b317972 (patch)
treeb46843f6faa90586f1e36676485e678220712844
parent6a1ad33c07de846f15af48c7a01eb567d9263da3 (diff)
do not send triage comments in alerts
add a check into the Alerts script to skip comments that have `triage_report` set in extra. Otherwise we send these our in new_updates alerts.
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin/Triage.pm15
-rw-r--r--t/app/controller/admin/triage.t15
2 files changed, 29 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin/Triage.pm b/perllib/FixMyStreet/App/Controller/Admin/Triage.pm
index 42028a6f0..9d6d96e44 100644
--- a/perllib/FixMyStreet/App/Controller/Admin/Triage.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin/Triage.pm
@@ -131,7 +131,7 @@ sub update : Private {
$extra->{new_category} = $new_category;
my $timestamp = \'current_timestamp';
- $problem->add_to_comments( {
+ my $comment = $problem->add_to_comments( {
text => "Report triaged from $current_category to $new_category",
created => $timestamp,
confirmed => $timestamp,
@@ -143,6 +143,19 @@ sub update : Private {
problem_state => $problem->state,
extra => $extra
} );
+
+ my @alerts = FixMyStreet::DB->resultset('Alert')->search( {
+ alert_type => 'new_updates',
+ parameter => $problem->id,
+ confirmed => 1,
+ } );
+
+ for my $alert (@alerts) {
+ my $alerts_sent = FixMyStreet::DB->resultset('AlertSent')->find_or_create( {
+ alert_id => $alert->id,
+ parameter => $comment->id,
+ } );
+ }
}
}
diff --git a/t/app/controller/admin/triage.t b/t/app/controller/admin/triage.t
index 81eb28a5d..0bc253150 100644
--- a/t/app/controller/admin/triage.t
+++ b/t/app/controller/admin/triage.t
@@ -1,4 +1,5 @@
use FixMyStreet::TestMech;
+use FixMyStreet::Script::Alerts;
my $mech = FixMyStreet::TestMech->new;
@@ -76,6 +77,16 @@ FixMyStreet::override_config {
my $report_url = '/report/' . $report->id;
$mech->get_ok($report_url);
+ my $alert = FixMyStreet::App->model('DB::Alert')->create(
+ {
+ user => $user2,
+ alert_type => 'new_updates',
+ parameter => $report->id,
+ parameter2 => '',
+ confirmed => 1,
+ }
+ );
+
$mech->content_contains('Traffic lights');
$mech->submit_form_ok( {
@@ -106,6 +117,10 @@ FixMyStreet::override_config {
$mech->log_out_ok;
$mech->get_ok($report_url);
$mech->content_lacks('Report triaged from Potholes to Traffic lights');
+
+ $mech->clear_emails_ok;
+ FixMyStreet::Script::Alerts::send();
+ $mech->email_count_is(0);
};
};