diff options
author | Matthew Somerville <matthew@mysociety.org> | 2019-12-11 11:05:30 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2019-12-11 11:32:21 +0000 |
commit | 698dc8fc34f728ca4d302f9f7ad0dc6801c5e259 (patch) | |
tree | 6139bf2d2297071de77ca803bb2e5ad929f4f98a | |
parent | d31201ac8cbc724ecb04d1a4744186876d2d5f5b (diff) |
[TfL] Fix reference ID in logged email.
If report made on .com, `body->get_cobrand_handler` does not return TfL
as it covers many bodies. Now we have the body handler, we can use that
instead.
-rw-r--r-- | perllib/FixMyStreet/Script/Reports.pm | 9 | ||||
-rw-r--r-- | t/cobrand/tfl.t | 19 |
2 files changed, 11 insertions, 17 deletions
diff --git a/perllib/FixMyStreet/Script/Reports.pm b/perllib/FixMyStreet/Script/Reports.pm index aed4e2fc6..73c179751 100644 --- a/perllib/FixMyStreet/Script/Reports.pm +++ b/perllib/FixMyStreet/Script/Reports.pm @@ -129,19 +129,12 @@ sub send(;$) { $missing = join(' / ', @missing) if @missing; } - my $send_confirmation_email = $cobrand->report_sent_confirmation_email; + my $send_confirmation_email = $cobrand_handler->report_sent_confirmation_email; my @dear; my %reporters = (); my $skip = 0; while (my $body = $bodies->next) { - # See if this body wants confirmation email (in case report made on national site, for example) - if (my $cobrand_body = $body->get_cobrand_handler) { - if (my $id_ref = $cobrand_body->report_sent_confirmation_email) { - $send_confirmation_email = $id_ref; - } - } - my $sender_info = $cobrand->get_body_sender( $body, $row->category ); my $sender = "FixMyStreet::SendReport::" . $sender_info->{method}; diff --git a/t/cobrand/tfl.t b/t/cobrand/tfl.t index 86b172f5a..ef6ca087c 100644 --- a/t/cobrand/tfl.t +++ b/t/cobrand/tfl.t @@ -384,16 +384,16 @@ subtest "change category, report resent to new location" => sub { }; for my $test ( - [ 'BR1 3UH', 'tfl.fixmystreet.com', 'Trees', 'TfL <bromley@example.com>', 'Bromley borough team' ], - [ 'BR1 3UH', 'www.fixmystreet.com', 'Trees', 'TfL <bromley@example.com>', 'Bromley borough team' ], - [ 'BR1 3UH', 'bromley.fixmystreet.com', 'Trees', 'TfL <bromley@example.com>', 'Bromley borough team' ], - [ 'TW7 5JN', 'tfl.fixmystreet.com', 'Trees', 'TfL <hounslow@example.com>', 'Hounslow borough team' ], - [ 'TW7 5JN', 'www.fixmystreet.com', 'Trees', 'TfL <hounslow@example.com>', 'Hounslow borough team' ], - [ 'TW7 5JN', 'tfl.fixmystreet.com', 'Grit bins', 'TfL <hounslow@example.com>, TfL <gritbins@example.com>', 'Hounslow borough team and additional address' ], - [ 'TW7 5JN', 'www.fixmystreet.com', 'Grit bins', 'TfL <hounslow@example.com>, TfL <gritbins@example.com>', 'Hounslow borough team and additional address' ], + [ 'BR1 3UH', 'tfl.fixmystreet.com', 'Trees', 'TfL <bromley@example.com>', 'Bromley borough team', 'reference number is FMS' ], + [ 'BR1 3UH', 'www.fixmystreet.com', 'Trees', 'TfL <bromley@example.com>', 'Bromley borough team', 'reference number is' ], + [ 'BR1 3UH', 'bromley.fixmystreet.com', 'Trees', 'TfL <bromley@example.com>', 'Bromley borough team', '' ], + [ 'TW7 5JN', 'tfl.fixmystreet.com', 'Trees', 'TfL <hounslow@example.com>', 'Hounslow borough team', 'reference number is FMS' ], + [ 'TW7 5JN', 'www.fixmystreet.com', 'Trees', 'TfL <hounslow@example.com>', 'Hounslow borough team', 'reference number is' ], + [ 'TW7 5JN', 'tfl.fixmystreet.com', 'Grit bins', 'TfL <hounslow@example.com>, TfL <gritbins@example.com>', 'Hounslow borough team and additional address', 'reference number is FMS' ], + [ 'TW7 5JN', 'www.fixmystreet.com', 'Grit bins', 'TfL <hounslow@example.com>, TfL <gritbins@example.com>', 'Hounslow borough team and additional address', 'reference number is' ], ) { - my ($postcode, $host, $category, $to, $name ) = @$test; - subtest "test report is sent to $name" => sub { + my ($postcode, $host, $category, $to, $name, $ref ) = @$test; + subtest "test report is sent to $name on $host" => sub { $mech->host($host); $mech->log_in_ok( $user->email ); $mech->get_ok('/around'); @@ -423,6 +423,7 @@ for my $test ( my @email = $mech->get_email; is $email[0]->header('To'), $to, 'Sent to correct address'; like $mech->get_text_body_from_email($email[0]), qr/https:\/\/street.tfl/, 'Correct link'; + like $mech->get_text_body_from_email($email[1]), qr/$ref/, "Correct reference number in reporter email" if $ref; $mech->clear_emails_ok; FixMyStreet::DB->resultset("Problem")->find({ title => 'Test Report for borough team'})->delete; }; |