aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App.pm5
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm18
-rw-r--r--perllib/FixMyStreet/Cobrand/FixMyStreet.pm7
-rw-r--r--perllib/FixMyStreet/Cobrand/UKCouncils.pm10
-rw-r--r--perllib/FixMyStreet/Email.pm8
-rw-r--r--t/cobrand/bromley.t62
-rw-r--r--templates/email/fixmystreet.com/signature.txt (renamed from templates/email/fixmystreet/signature.txt)0
-rw-r--r--templates/email/fixmystreet.com/submit-oxfordshire.txt (renamed from templates/email/fixmystreet/submit-oxfordshire.txt)0
-rw-r--r--templates/email/fixmystreet.com/submit.txt (renamed from templates/email/fixmystreet/submit.txt)0
-rw-r--r--templates/email/fixmystreet.com/update-confirm-donotsend.txt (renamed from templates/email/fixmystreet/update-confirm-donotsend.txt)0
10 files changed, 100 insertions, 10 deletions
diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm
index 1a651d282..be0e91101 100644
--- a/perllib/FixMyStreet/App.pm
+++ b/perllib/FixMyStreet/App.pm
@@ -310,10 +310,7 @@ sub send_email {
from => [ $sender, _($sender_name) ],
%{ $c->stash },
%$extra_stash_values,
- additional_template_paths => [
- FixMyStreet->path_to( 'templates', 'email', $c->cobrand->moniker, $c->stash->{lang_code} )->stringify,
- FixMyStreet->path_to( 'templates', 'email', $c->cobrand->moniker )->stringify,
- ]
+ additional_template_paths => $c->cobrand->path_to_email_templates($c->stash->{lang_code}),
};
return if FixMyStreet::Email::is_abuser($c->model('DB')->schema, $vars->{to});
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 4dc024d48..ee71f583f 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -32,6 +32,24 @@ sub path_to_web_templates {
return $paths;
}
+=head1 path_to_email_templates
+
+ $path = $cobrand->path_to_email_templates( );
+
+Returns the path to the email templates for this cobrand - by default
+"templates/email/$moniker" (and then default in Email.pm).
+
+=cut
+
+sub path_to_email_templates {
+ my ( $self, $lang_code ) = @_;
+ my $paths = [
+ FixMyStreet->path_to( 'templates', 'email', $self->moniker, $lang_code )->stringify,
+ FixMyStreet->path_to( 'templates', 'email', $self->moniker )->stringify,
+ ];
+ return $paths;
+}
+
=head1 country
Returns the country that this cobrand operates in, as an ISO3166-alpha2 code.
diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
index c8c1eef66..d3de9da3a 100644
--- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
+++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
@@ -10,6 +10,13 @@ sub path_to_web_templates {
FixMyStreet->path_to( 'templates/web/fixmystreet.com' )->stringify,
];
}
+sub path_to_email_templates {
+ my ( $self, $lang_code ) = @_;
+ return [
+ FixMyStreet->path_to( 'templates', 'email', 'fixmystreet.com')->stringify,
+ ];
+}
+
# FixMyStreet should return all cobrands
sub restriction {
diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
index 0321e0297..d9e8f8673 100644
--- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm
+++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
@@ -21,6 +21,16 @@ sub path_to_web_templates {
];
}
+sub path_to_email_templates {
+ my ( $self, $lang_code ) = @_;
+ my $paths = [
+ FixMyStreet->path_to( 'templates', 'email', $self->moniker, $lang_code )->stringify,
+ FixMyStreet->path_to( 'templates', 'email', $self->moniker )->stringify,
+ FixMyStreet->path_to( 'templates', 'email', 'fixmystreet.com')->stringify,
+ ];
+ return $paths;
+}
+
sub site_key {
my $self = shift;
return $self->council_url;
diff --git a/perllib/FixMyStreet/Email.pm b/perllib/FixMyStreet/Email.pm
index ce7dad47a..b12fcfab4 100644
--- a/perllib/FixMyStreet/Email.pm
+++ b/perllib/FixMyStreet/Email.pm
@@ -92,13 +92,11 @@ sub send_cron {
unpack('h*', random_bytes(5, 1)), FixMyStreet->config('EMAIL_DOMAIN')
);
+ my @include_path = @{ $cobrand->path_to_email_templates($lang_code) };
+ push @include_path, FixMyStreet->path_to( 'templates', 'email', 'default' )->stringify;
my $tt = Template->new({
ENCODING => 'utf8',
- INCLUDE_PATH => [
- FixMyStreet->path_to( 'templates', 'email', $cobrand->moniker, $lang_code )->stringify,
- FixMyStreet->path_to( 'templates', 'email', $cobrand->moniker )->stringify,
- FixMyStreet->path_to( 'templates', 'email', 'default' )->stringify,
- ],
+ INCLUDE_PATH => \@include_path,
});
$vars->{signature} = _render_template($tt, 'signature.txt', $vars);
$vars->{site_name} = Utils::trim_text(_render_template($tt, 'site-name.txt', $vars));
diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t
index 1f61cd3de..6066c66b6 100644
--- a/t/cobrand/bromley.t
+++ b/t/cobrand/bromley.t
@@ -7,7 +7,7 @@ my $mech = FixMyStreet::TestMech->new;
# Create test data
my $user = $mech->create_user_ok( 'bromley@example.com' );
-my $body = $mech->create_body_ok( 2482, 'Bromley', id => 2482 );
+my $body = $mech->create_body_ok( 2482, 'Bromley Council', id => 2482 );
$mech->create_contact_ok(
body_id => $body->id,
category => 'Other',
@@ -56,6 +56,66 @@ subtest 'testing special Open311 behaviour', sub {
is $report->external_id, 248, 'Report has right external ID';
};
+for my $test (
+ {
+ cobrand => 'bromley',
+ fields => {
+ submit_update => 1,
+ rznvy => 'unregistered@example.com',
+ update => 'Update from an unregistered user',
+ add_alert => undef,
+ first_name => 'Unreg',
+ last_name => 'User',
+ fms_extra_title => 'DR',
+ may_show_name => undef,
+ }
+ },
+ {
+ cobrand => 'fixmystreet',
+ fields => {
+ submit_update => 1,
+ rznvy => 'unregistered@example.com',
+ update => 'Update from an unregistered user',
+ add_alert => undef,
+ name => 'Unreg User',
+ fms_extra_title => 'DR',
+ may_show_name => undef,
+ }
+ },
+)
+{
+ subtest 'check Bromley update emails via ' . $test->{cobrand} . ' cobrand are correct' => sub {
+ $mech->log_out_ok();
+ $mech->clear_emails_ok();
+
+ my $report_id = $report->id;
+
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ $test->{cobrand} ],
+ }, sub {
+ $mech->get_ok("/report/$report_id");
+ $mech->submit_form_ok(
+ {
+ with_fields => $test->{fields}
+ },
+ 'submit update'
+ );
+ };
+ $mech->content_contains('Nearly done! Now check your email');
+
+ my $email = $mech->get_email;
+ ok $email, "got an email";
+ like $email->body, qr/This update will be sent to Bromley Council/i, "Email indicates problem will be sent to Bromley";
+ unlike $email->body, qr/Note that we do not send updates to/i, "Email does not say updates aren't sent to Bromley";
+
+ my $unreg_user = FixMyStreet::App->model( 'DB::User' )->find( { email => 'unregistered@example.com' } );
+
+ ok $unreg_user, 'found user';
+
+ $mech->delete_user( $unreg_user );
+ };
+}
+
# Clean up
$mech->delete_user($user);
$mech->delete_body($body);
diff --git a/templates/email/fixmystreet/signature.txt b/templates/email/fixmystreet.com/signature.txt
index 834e69b9d..834e69b9d 100644
--- a/templates/email/fixmystreet/signature.txt
+++ b/templates/email/fixmystreet.com/signature.txt
diff --git a/templates/email/fixmystreet/submit-oxfordshire.txt b/templates/email/fixmystreet.com/submit-oxfordshire.txt
index f0fc5e9b7..f0fc5e9b7 100644
--- a/templates/email/fixmystreet/submit-oxfordshire.txt
+++ b/templates/email/fixmystreet.com/submit-oxfordshire.txt
diff --git a/templates/email/fixmystreet/submit.txt b/templates/email/fixmystreet.com/submit.txt
index 17642e645..17642e645 100644
--- a/templates/email/fixmystreet/submit.txt
+++ b/templates/email/fixmystreet.com/submit.txt
diff --git a/templates/email/fixmystreet/update-confirm-donotsend.txt b/templates/email/fixmystreet.com/update-confirm-donotsend.txt
index 2e04dc0bf..2e04dc0bf 100644
--- a/templates/email/fixmystreet/update-confirm-donotsend.txt
+++ b/templates/email/fixmystreet.com/update-confirm-donotsend.txt