aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2020-01-20 17:56:55 +0000
committerMatthew Somerville <matthew@mysociety.org>2020-01-21 14:28:17 +0000
commitd8cb50810ceab27e7090844faabceadf89a7be4e (patch)
treef71ed7d5aa46d825994d13848e612b0cdd9115af
parentccbab6a38132db50d7a2cd434e6a8c5caf1bb859 (diff)
[TfL] Always use TfL branding on shortlist email.
It was using the branding/URL of the site the update was left on.
-rw-r--r--perllib/FixMyStreet/App.pm2
-rw-r--r--perllib/FixMyStreet/Cobrand/TfL.pm8
-rw-r--r--t/cobrand/tfl.t27
-rw-r--r--templates/email/tfl/signature.txt1
4 files changed, 27 insertions, 11 deletions
diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm
index 1b75b9ba2..6a41d93a9 100644
--- a/perllib/FixMyStreet/App.pm
+++ b/perllib/FixMyStreet/App.pm
@@ -368,8 +368,8 @@ sub construct_email {
my $vars = {
from => [ $sender, _($sender_name) ],
%{ $c->stash },
- %$extra_stash_values,
additional_template_paths => \@include_path,
+ %$extra_stash_values,
};
$vars->{site_name} = Utils::trim_text($c->view('EmailText')->render($c, 'site-name.txt', $vars));
$vars->{signature} = $c->view('EmailText')->render($c, 'signature.txt', $vars);
diff --git a/perllib/FixMyStreet/Cobrand/TfL.pm b/perllib/FixMyStreet/Cobrand/TfL.pm
index 5183e00c9..10c94f5cc 100644
--- a/perllib/FixMyStreet/Cobrand/TfL.pm
+++ b/perllib/FixMyStreet/Cobrand/TfL.pm
@@ -313,12 +313,18 @@ sub must_have_2fa {
sub update_email_shortlisted_user {
my ($self, $update) = @_;
my $c = $self->{c};
+ my $cobrand = FixMyStreet::Cobrand::TfL->new; # $self may be FMS
my $shortlisted_by = $update->problem->shortlisted_user;
if ($shortlisted_by && $shortlisted_by->from_body && $shortlisted_by->from_body->name eq 'TfL' && $shortlisted_by->id ne $update->user_id) {
$c->send_email('alert-update.txt', {
+ additional_template_paths => [
+ FixMyStreet->path_to( 'templates', 'email', 'tfl' ),
+ FixMyStreet->path_to( 'templates', 'email', 'fixmystreet.com'),
+ ],
to => [ [ $shortlisted_by->email, $shortlisted_by->name ] ],
report => $update->problem,
- problem_url => $c->cobrand->base_url_for_report($update->problem) . $update->problem->url,
+ cobrand => $cobrand,
+ problem_url => $cobrand->base_url . $update->problem->url,
data => [ {
item_photo => $update->photo,
item_text => $update->text,
diff --git a/t/cobrand/tfl.t b/t/cobrand/tfl.t
index 61d851422..24185993b 100644
--- a/t/cobrand/tfl.t
+++ b/t/cobrand/tfl.t
@@ -592,15 +592,24 @@ subtest 'TfL admin allows inspectors to be assigned to borough areas' => sub {
$staffuser->update({ area_ids => undef}); # so login below doesn't break
};
-subtest 'Leave an update on a shortlisted report, get an email' => sub {
- my $report = FixMyStreet::DB->resultset("Problem")->find({ title => 'Test Report 1'});
- $staffuser->add_to_planned_reports($report);
- $mech->log_in_ok( $user->email );
- $mech->get_ok('/report/' . $report->id);
- $mech->submit_form_ok({ with_fields => { update => 'This is an update' }});
- my $email = $mech->get_text_body_from_email;
- like $email, qr/This is an update/;
-};
+my $report = FixMyStreet::DB->resultset("Problem")->find({ title => 'Test Report 1'});
+$report->update({ cobrand => 'fixmystreet' });
+$staffuser->add_to_planned_reports($report);
+
+for my $host ( 'www.fixmystreet.com', 'tfl.fixmystreet.com' ) {
+ subtest "Leave an update on a shortlisted report on $host, get an email" => sub {
+ $mech->host($host);
+ $mech->log_in_ok( $user->email );
+ $mech->get_ok('/report/' . $report->id);
+ $mech->submit_form_ok({ with_fields => { update => 'This is an update' }});
+ my $email = $mech->get_email;
+ my $text = $mech->get_text_body_from_email;
+ like $text, qr/This is an update/, 'Right email';
+ like $text, qr/street.tfl/, 'Right url';
+ like $text, qr/Street Care/, 'Right name';
+ like $email->as_string, qr/iEYI87gX6Upb\+tKYzrSmN83pTnv606AOtahHTepSm/, 'Right logo';
+ };
+}
subtest 'TfL staff can access TfL admin' => sub {
$mech->log_in_ok( $staffuser->email );
diff --git a/templates/email/tfl/signature.txt b/templates/email/tfl/signature.txt
new file mode 100644
index 000000000..ef8d7d667
--- /dev/null
+++ b/templates/email/tfl/signature.txt
@@ -0,0 +1 @@
+Street Care