diff options
author | Dave Arter <davea@mysociety.org> | 2016-06-15 12:02:53 +0100 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2016-06-15 14:10:33 +0100 |
commit | b5b3b8e3cee367a8f82b4179a5d03f4d30e1215e (patch) | |
tree | d794ea247a6b5a2c7dcff42e77990217eacb02e9 /t/cobrand | |
parent | 96c72fa72e547a2ce5b435db3cae8c3c45efafc1 (diff) |
[UK Councils] Send correct confirm emails for updates
Some UK councils with Open311 integrations (e.g. Bromley) have a custom wording
in the confirmation email sent when updates are left on reports, to make the
user aware that the update is sent to the council in question.
Bromley noticed that some emails were being sent without this wording, leading
at least one user to contact the council directly about the report.
It turns out that although the email template contains an IF clause to use the
appropriate wording for Bromley (and Stevenage) reports, the incorrect template
file was being used when updates were made via the Bromley cobrand.
This commit solves the problem by introducing a new
`Cobrand::Default::path_to_email_templates` method, which is overridden by
`Cobrand::UKCouncils` to include the `templates/email/fixmystreet` path. Paths
returned by this method are used as the `additional_template_paths` param when
templating emails. A regression test is included.
Additionally moves email templates for fixmystreet.com to a directory name
reflecting their purpose, in the same way the web templates are arranged.
Diffstat (limited to 't/cobrand')
-rw-r--r-- | t/cobrand/bromley.t | 62 |
1 files changed, 61 insertions, 1 deletions
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); |