aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2019-11-08 11:46:20 +0000
committerDave Arter <davea@mysociety.org>2019-12-09 12:50:07 +0000
commitf4157d76048d14711883cc2bba75bef663696aae (patch)
treebb79c3653700c638779cd3719e595a1d901af0dd
parentc75acd2a3e8cc5abc10ea6ba116a078ca881944d (diff)
[TfL] Resend report upon category change.
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin/Reports.pm4
-rw-r--r--perllib/FixMyStreet/Cobrand/TfL.pm2
-rw-r--r--t/cobrand/tfl.t16
3 files changed, 22 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin/Reports.pm b/perllib/FixMyStreet/App/Controller/Admin/Reports.pm
index bee2ed498..91b086637 100644
--- a/perllib/FixMyStreet/App/Controller/Admin/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin/Reports.pm
@@ -382,6 +382,7 @@ sub edit_category : Private {
my ($self, $c, $problem, $no_comment) = @_;
if ((my $category = $c->get_param('category')) ne $problem->category) {
+ my $force_resend = $c->cobrand->call_hook('category_change_force_resend');
my $disable_resend = $c->cobrand->call_hook('disable_resend');
my $category_old = $problem->category;
$problem->category($category);
@@ -403,6 +404,9 @@ sub edit_category : Private {
if (!$disable_resend && grep !$old_send_methods{$_}, @new_send_methods) {
$problem->resend;
}
+ if ($force_resend) {
+ $problem->resend;
+ }
$problem->bodies_str(join( ',', @new_body_ids ));
my $update_text = '*' . sprintf(_('Category changed from ā€˜%s’ to ā€˜%s’'), $category_old, $category) . '*';
diff --git a/perllib/FixMyStreet/Cobrand/TfL.pm b/perllib/FixMyStreet/Cobrand/TfL.pm
index ba5d8b171..92fbc1529 100644
--- a/perllib/FixMyStreet/Cobrand/TfL.pm
+++ b/perllib/FixMyStreet/Cobrand/TfL.pm
@@ -22,6 +22,8 @@ sub is_council { 0 }
sub send_questionnaires { 0 }
+sub category_change_force_resend { 1 }
+
sub area_check {
my ( $self, $params, $context ) = @_;
diff --git a/t/cobrand/tfl.t b/t/cobrand/tfl.t
index 14f7dce08..b8e88a300 100644
--- a/t/cobrand/tfl.t
+++ b/t/cobrand/tfl.t
@@ -217,6 +217,22 @@ subtest 'Dashboard CSV extra columns' => sub {
$mech->content_contains(',,,yes,busstops@example.com,,' . $dt . ',"Council User"');
};
+subtest "change category, report resent to new location" => sub {
+ my $report = FixMyStreet::DB->resultset("Problem")->find({ title => 'Test Report 1'});
+ my $id = $report->id;
+
+ $mech->log_in_ok( $superuser->email );
+ $mech->get_ok("/admin/report_edit/$id");
+ $mech->submit_form_ok({ with_fields => { category => 'Traffic lights' } });
+
+ FixMyStreet::Script::Reports::send();
+ my @email = $mech->get_email;
+ is $email[0]->header('To'), 'TfL <trafficlights@example.com>';
+ $mech->clear_emails_ok;
+
+ $mech->log_out_ok;
+};
+
subtest 'check lookup by reference' => sub {
my $id = FixMyStreet::DB->resultset("Problem")->first->id;