aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/app/controller/reports.t2
-rw-r--r--t/app/helpers/send_email.t10
-rw-r--r--t/app/helpers/send_email_sample.txt2
-rw-r--r--t/app/helpers/send_email_sample_mime.txt2
-rw-r--r--t/app/model/alert_type.t27
-rw-r--r--t/cobrand/isleofwight.t2
-rw-r--r--t/cobrand/zurich.t17
-rw-r--r--t/template.t33
8 files changed, 70 insertions, 25 deletions
diff --git a/t/app/controller/reports.t b/t/app/controller/reports.t
index ac230ef95..670c5cfc3 100644
--- a/t/app/controller/reports.t
+++ b/t/app/controller/reports.t
@@ -139,7 +139,7 @@ FixMyStreet::override_config {
is $mech->uri->path, '/reports/Birmingham/Bordesley+and+Highgate';
$mech->get_ok('/reports/Birmingham/Bordesley+and+Highgate|Birchfield');
is $mech->uri->path, '/reports/Birmingham/Bordesley+and+Highgate%7CBirchfield';
- $mech->content_contains('Birchfield, Bordesley & Highgate');
+ $mech->content_contains('Birchfield, Bordesley & Highgate');
};
$mech->get_ok('/reports/Westminster');
diff --git a/t/app/helpers/send_email.t b/t/app/helpers/send_email.t
index 58b9acaaa..522ee39d0 100644
--- a/t/app/helpers/send_email.t
+++ b/t/app/helpers/send_email.t
@@ -17,7 +17,7 @@ my $mech = FixMyStreet::TestMech->new;
my $c = ctx_request("/");
# set some values in the stash
-$c->stash->{foo} = 'bar';
+$c->stash->{foo} = 'bar <b>bold</b>';
# clear the email queue
$mech->clear_emails_ok;
@@ -118,6 +118,14 @@ subtest 'Inline emails!' => sub {
\ {10}\+\ text/plain.*\n
\ {10}\+\ text/html.*\n
\ {5}\+\ image/gif]x;
+ $email->walk_parts(sub {
+ my ($part) = @_;
+ if ($part->content_type =~ m[text/plain]i) {
+ like $part->body_str, qr/foo: bar <b>bold<\/b>/;
+ } elsif ($part->content_type =~ m[text/html]i) {
+ like $part->body_str, qr/foo: bar &lt;b&gt;bold&lt;\/b&gt;/;
+ }
+ });
$mech->clear_emails_ok;
};
diff --git a/t/app/helpers/send_email_sample.txt b/t/app/helpers/send_email_sample.txt
index 68fe61f0e..e14c536be 100644
--- a/t/app/helpers/send_email_sample.txt
+++ b/t/app/helpers/send_email_sample.txt
@@ -7,7 +7,7 @@ From: CONTACT_EMAIL
Hello,
-This is a test email where foo: bar.
+This is a test email where foo: bar <b>bold</b>.
utf8: =E6=88=91=E4=BB=AC=E5=BA=94=E8=AF=A5=E8=83=BD=E5=A4=9F=E6=97=A0=E7=BC=
=9D=E5=A4=84=E7=90=86UTF8=E7=BC=96=E7=A0=81
diff --git a/t/app/helpers/send_email_sample_mime.txt b/t/app/helpers/send_email_sample_mime.txt
index 7b4ce91f6..623874149 100644
--- a/t/app/helpers/send_email_sample_mime.txt
+++ b/t/app/helpers/send_email_sample_mime.txt
@@ -12,7 +12,7 @@ Content-Transfer-Encoding: quoted-printable
Hello,
-This is a test email where foo: bar.
+This is a test email where foo: bar <b>bold</b>.
utf8: =E6=88=91=E4=BB=AC=E5=BA=94=E8=AF=A5=E8=83=BD=E5=A4=9F=E6=97=A0=E7=BC=
=9D=E5=A4=84=E7=90=86UTF8=E7=BC=96=E7=A0=81
diff --git a/t/app/model/alert_type.t b/t/app/model/alert_type.t
index ecca2df3d..42bed37eb 100644
--- a/t/app/model/alert_type.t
+++ b/t/app/model/alert_type.t
@@ -337,6 +337,8 @@ foreach my $test (
};
}
+my $hart = $mech->create_body_ok(2333, 'Hart');
+
my $ward_alert = FixMyStreet::DB->resultset('Alert')->find_or_create(
{
user => $user,
@@ -351,7 +353,7 @@ my $ward_alert = FixMyStreet::DB->resultset('Alert')->find_or_create(
my $report_to_council = FixMyStreet::DB->resultset('Problem')->find_or_create(
{
postcode => 'WS13 6YY',
- bodies_str => '2434',
+ bodies_str => $hart->id,
areas => ',105255,11806,11828,2247,2504,7117,',
category => 'Other',
title => 'council report',
@@ -375,7 +377,7 @@ my $report_to_council = FixMyStreet::DB->resultset('Problem')->find_or_create(
my $report_to_county_council = FixMyStreet::DB->resultset('Problem')->find_or_create(
{
postcode => 'WS13 6YY',
- bodies_str => '2240',
+ bodies_str => '2227',
areas => ',105255,11806,11828,2247,2504,7117,',
category => 'Other',
title => 'county report',
@@ -430,21 +432,22 @@ subtest "check alerts from cobrand send main site url for alerts for different c
)->delete;
FixMyStreet::override_config {
+ ALLOWED_COBRANDS => ['hart', 'fixmystreet'],
+ BASE_URL => 'https://national.example.org',
MAPIT_URL => 'http://mapit.uk/',
}, sub {
FixMyStreet::DB->resultset('AlertType')->email_alerts();
- };
-
- my $body = $mech->get_text_body_from_email;
- my $expected1 = FixMyStreet->config('BASE_URL') . '/report/' . $report_to_county_council->id;
- my $expected3 = FixMyStreet->config('BASE_URL') . '/report/' . $report_outside_district->id;
- my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker('hart')->new();
- my $expected2 = $cobrand->base_url . '/report/' . $report_to_council->id;
+ my $body = $mech->get_text_body_from_email;
- like $body, qr#$expected1#, 'non cobrand area report point to fixmystreet.com';
- like $body, qr#$expected2#, 'cobrand area report point to cobrand url';
- like $body, qr#$expected3#, 'report outside district report point to fixmystreet.com';
+ my $expected1 = FixMyStreet->config('BASE_URL') . '/report/' . $report_to_county_council->id;
+ my $expected3 = FixMyStreet->config('BASE_URL') . '/report/' . $report_outside_district->id;
+ my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker('hart')->new();
+ my $expected2 = $cobrand->base_url . '/report/' . $report_to_council->id;
+ like $body, qr#$expected1#, 'non cobrand area report point to fixmystreet.com';
+ like $body, qr#$expected2#, 'cobrand area report point to cobrand url';
+ like $body, qr#$expected3#, 'report outside district report point to fixmystreet.com';
+ };
};
diff --git a/t/cobrand/isleofwight.t b/t/cobrand/isleofwight.t
index 9e1b80c68..c28c30503 100644
--- a/t/cobrand/isleofwight.t
+++ b/t/cobrand/isleofwight.t
@@ -425,7 +425,7 @@ subtest "check not responsible as correct text" => sub {
$mech->get_ok('/report/' . $p->id);
};
- $mech->content_contains("not Island Roads' responsibility", "not reponsible message contains correct text");
+ $mech->content_contains("not Island Roads&#39; responsibility", "not reponsible message contains correct text");
$p->comments->delete;
$p->delete;
};
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t
index 6825caccf..b82d50b68 100644
--- a/t/cobrand/zurich.t
+++ b/t/cobrand/zurich.t
@@ -1,6 +1,7 @@
# TODO
# Overdue alerts
+use utf8;
use DateTime;
use Email::MIME;
use File::Temp;
@@ -109,11 +110,11 @@ my @reports = $mech->create_problems_for_body( 1, $division->id, 'Test', {
my $report = $reports[0];
$mech->get_ok( '/report/' . $report->id );
-$mech->content_contains('&Uuml;berpr&uuml;fung ausstehend')
+$mech->content_contains('Überprüfung ausstehend')
or die $mech->content;
my $json = $mech->get_ok_json( '/report/ajax/' . $report->id );
-is $json->{report}->{title}, "&Uuml;berpr&uuml;fung ausstehend", "correct title";
+is $json->{report}->{title}, "Überprüfung ausstehend", "correct title";
is $json->{report}->{state}, "submitted", "correct state";
subtest "Banners are displayed correctly" => sub {
@@ -308,7 +309,7 @@ subtest "report_edit" => sub {
$mech->log_in_ok( 'dm1@example.org') ;
$mech->get_ok( '/admin/report_edit/' . $report->id );
- $mech->content_contains( 'Unbest&auml;tigt' ); # Unconfirmed email
+ $mech->content_contains( 'Unbestätigt' ); # Unconfirmed email
$mech->submit_form_ok( { with_fields => { state => 'confirmed' } } );
$mech->get_ok( '/report/' . $report->id );
@@ -538,7 +539,7 @@ subtest 'Test publishing of final update by DM' => sub {
$mech->content_contains('Admin district');
- $mech->content_lacks( 'Unbest&auml;tigt' ); # Confirmed email
+ $mech->content_lacks( 'Unbestätigt' ); # Confirmed email
$mech->submit_form_ok( { with_fields => { status_update => 'FINAL UPDATE' } } );
$mech->form_with_fields( 'status_update' );
$mech->submit_form_ok( { button => 'publish_response' } );
@@ -573,7 +574,7 @@ subtest "Assign feedback pending (via confirmed), don't confirm email, no email
$mech->content_contains('Second Test');
$mech->get_ok( '/admin/report_edit/' . $report->id );
- $mech->content_contains( 'Unbest&auml;tigt' );
+ $mech->content_contains( 'Unbestätigt' );
$report->discard_changes;
$mech->form_with_fields( 'status_update' );
$mech->submit_form_ok( { button => 'publish_response', with_fields => { status_update => 'FINAL UPDATE' } } );
@@ -757,7 +758,7 @@ subtest "phone number is mandatory" => sub {
$user = $mech->log_in_ok( 'dm1@example.org' );
$mech->get_ok( '/report/new?lat=47.381817&lon=8.529156' );
$mech->submit_form( with_fields => { phone => "" } );
- $mech->content_contains( 'Diese Information wird ben&ouml;tigt' );
+ $mech->content_contains( 'Diese Information wird benötigt' );
$mech->log_out_ok;
};
@@ -774,7 +775,7 @@ subtest "phone number is not mandatory for reports from mobile apps" => sub {
});
my $res = $mech->response;
ok $res->header('Content-Type') =~ m{^application/json\b}, 'response should be json';
- unlike $res->content, qr/Diese Information wird ben&ouml;tigt/, 'response should not contain phone error';
+ unlike $res->content, qr/Diese Information wird benötigt/, 'response should not contain phone error';
# Clear out the mailq
$mech->clear_emails_ok;
};
@@ -861,7 +862,7 @@ subtest "test stats" => sub {
is $mech->res->code, 200, "superuser should be able to see stats page";
$mech->content_contains('Innerhalb eines Arbeitstages moderiert: 3');
- $mech->content_contains('Innerhalb von f&uuml;nf Arbeitstagen abgeschlossen: 3');
+ $mech->content_contains('Innerhalb von fünf Arbeitstagen abgeschlossen: 3');
# my @data = $mech->content =~ /(?:moderiert|abgeschlossen): \d+/g;
# diag Dumper(\@data); use Data::Dumper;
diff --git a/t/template.t b/t/template.t
new file mode 100644
index 000000000..1763a7f12
--- /dev/null
+++ b/t/template.t
@@ -0,0 +1,33 @@
+use FixMyStreet::Test;
+
+use_ok 'FixMyStreet::Template';
+
+my $tt = FixMyStreet::Template->new;
+
+my $output = '';
+$tt->process(\'[% s %] [% s | safe %] [% s | upper %] [% s | html %]', {
+ s => 'sp<i>l</i>it'
+}, \$output);
+is $output, 'sp&lt;i&gt;l&lt;/i&gt;it sp<i>l</i>it SP&lt;I&gt;L&lt;/I&gt;IT sp&lt;i&gt;l&lt;/i&gt;it';
+
+$output = '';
+$tt->process(\'[% s | html_para %]', { s => 'sp<i>l</i>it' }, \$output);
+is $output, "<p>\nsp&lt;i&gt;l&lt;/i&gt;it</p>\n";
+
+$output = '';
+$tt->process(\'[% loc("s") %] [% loc("s") | html_para %]', {}, \$output);
+is $output, "s <p>\ns</p>\n";
+
+$output = '';
+$tt->process(\'[% s.upper %] [% t = s %][% t %] [% t.upper %]', {
+ s => 'sp<i>l</i>it'
+}, \$output);
+is $output, 'SP&lt;I&gt;L&lt;/I&gt;IT sp&lt;i&gt;l&lt;/i&gt;it SP&lt;I&gt;L&lt;/I&gt;IT';
+
+$output = '';
+$tt->process(\'H: [% s.split(":").join(",") %]', {
+ s => '1:sp<i>l</i>it:3'
+}, \$output);
+is $output, 'H: 1,sp&lt;i&gt;l&lt;/i&gt;it,3';
+
+done_testing;