aboutsummaryrefslogtreecommitdiffstats
path: root/t/cobrand
diff options
context:
space:
mode:
Diffstat (limited to 't/cobrand')
-rw-r--r--t/cobrand/fixamingata.t8
-rw-r--r--t/cobrand/fixmybarangay.t150
-rw-r--r--t/cobrand/form_extras.t1
-rw-r--r--t/cobrand/loading.t30
-rw-r--r--t/cobrand/zurich.t7
-rw-r--r--t/cobrand/zurich_attachments.txt73
6 files changed, 58 insertions, 211 deletions
diff --git a/t/cobrand/fixamingata.t b/t/cobrand/fixamingata.t
index 50b7713d1..0cf7a31fe 100644
--- a/t/cobrand/fixamingata.t
+++ b/t/cobrand/fixamingata.t
@@ -46,10 +46,10 @@ FixMyStreet::override_config {
FixMyStreet::DB->resultset('Problem')->send_reports();
};
my $email = $mech->get_email;
-like $email->header('Content-Type'), qr/iso-8859-1/, 'encoding looks okay';
+like $email->header('Content-Type'), qr/utf-8/, 'encoding looks okay';
like $email->header('Subject'), qr/Ny rapport: Test Test/, 'subject looks okay';
like $email->header('To'), qr/other\@example.org/, 'to line looks correct';
-like $email->body, qr/V=E4nligen,/, 'signature looks correct';
+like $email->body_str, qr/V\xe4nligen,/, 'signature looks correct';
$mech->clear_emails_ok;
my $user =
@@ -91,8 +91,8 @@ FixMyStreet::override_config {
$mech->email_count_is(1);
$email = $mech->get_email;
-like $email->header('Content-Type'), qr/iso-8859-1/, 'encoding looks okay';
-like $email->body, qr/V=E4nligen,/, 'signature looks correct';
+like $email->header('Content-Type'), qr/utf-8/, 'encoding looks okay';
+like $email->body_str, qr/V\xe4nligen,/, 'signature looks correct';
$mech->clear_emails_ok;
subtest "Test ajax decimal points" => sub {
diff --git a/t/cobrand/fixmybarangay.t b/t/cobrand/fixmybarangay.t
deleted file mode 100644
index 2f99b8c1e..000000000
--- a/t/cobrand/fixmybarangay.t
+++ /dev/null
@@ -1,150 +0,0 @@
-use strict;
-use warnings;
-use Test::More;
-
-BEGIN {
- use FixMyStreet;
- FixMyStreet->test_mode(1);
-}
-
-use FixMyStreet::TestMech;
-my $mech = FixMyStreet::TestMech->new;
-
-# Front page test
-
-ok $mech->host("www.fixmybarangay.com"), "change host to FixMyBarangay";
-FixMyStreet::override_config {
- ALLOWED_COBRANDS => [ 'fixmybarangay' ],
-}, sub {
- $mech->get_ok('/');
-};
-$mech->content_like( qr/FixMyBarangay/ );
-
-# Set up bodies
-
-my $luz = $mech->create_body_ok( 1, 'Bgy Luz', id => 1 );
-$luz->update( { send_method => 'Email' } );
-
-my $bsn = $mech->create_body_ok( 2, 'Bgy BSN', id => 2 );
-$bsn->update( { send_method => 'Email' } );
-
-my $dps = $mech->create_body_ok( 3, 'DPS', id => 3 );
-$dps->update( { send_method => 'Open311', endpoint => 'http://dps.endpoint.example.com', jurisdiction => 'FMB', api_key => 'test' } );
-FixMyStreet::DB->resultset('BodyArea')->find_or_create({ area_id => 1, body_id => $dps->id });
-FixMyStreet::DB->resultset('BodyArea')->find_or_create({ area_id => 2, body_id => $dps->id });
-
-# Create contacts for these bodies
-# TODO: log in as a Bgy user, and create a report using the front end,
-# testing that the drop-down has the right things in it, and so on.
-
-$mech->create_contact_ok(
- body_id => $luz->id,
- category => 'Streetlight (BGY)',
- email => 'bgy@example.com',
-);
-$mech->create_contact_ok(
- body_id => $dps->id,
- category => 'Streetlight (DPS)',
- email => 'LIGHT',
-);
-
-# Create a couple of reports
-
-my @reports = $mech->create_problems_for_body( 1, $luz->id, 'Test', {
- cobrand => 'fixmybarangay',
- category => 'Streetlight (BGY)',
-});
-my $luz_report = $reports[0];
-
-@reports = $mech->create_problems_for_body( 1, $dps->id, 'Test', {
- cobrand => 'fixmybarangay',
- category => 'Streetlight (DPS)',
-});
-my $dps_report = $reports[0];
-
-$mech->get_ok( '/report/' . $luz_report->id );
-$mech->get_ok( '/report/' . $dps_report->id );
-
-# Send the reports
-
-$mech->email_count_is(0);
-
-FixMyStreet::override_config {
- SEND_REPORTS_ON_STAGING => 1,
-}, sub {
- FixMyStreet::DB->resultset('Problem')->send_reports('fixmybarangay');
-};
-
-# Check BGY one sent by email
-my $email = $mech->get_email;
-like $email->header('Subject'), qr/Problem Report: Test Test/, 'subject looks okay';
-like $email->header('To'), qr/bgy\@example.com/, 'to line looks correct';
-$mech->clear_emails_ok;
-
-$luz_report->discard_changes;
-$dps_report->discard_changes;
-ok $luz_report->whensent, 'Luz report marked as sent';
-ok $dps_report->whensent, 'DPS report marked as sent';
-is $dps_report->send_method_used, 'Open311', 'DPS report sent via Open311';
-is $dps_report->external_id, 248, 'DPS report has right external ID';
-
-my $fmb_test_email = 'luz_test_user@example.com';
-my $user = FixMyStreet::DB->resultset('User')->find_or_create( { email => $fmb_test_email, from_body => $luz->id, password => 'fmbsecret' } );
-ok $user, "test user does exist";
-
-my $alert = FixMyStreet::DB->resultset('Alert')->find_or_create({
- user => $user,
- parameter => '-0.142497580865087',
- parameter2 => '51.5016605453401',
- alert_type => 'local_problems',
- whensubscribed => '2014-01-01 10:00:00',
- confirmed => 1,
- cobrand => 'fixmybarangay',
-});
-
-FixMyStreet::override_config {
- ALLOWED_COBRANDS => [ 'fixmybarangay' ],
-}, sub {
- FixMyStreet::DB->resultset('AlertType')->email_alerts();
-};
-
-$mech->email_count_is(1);
-$email = $mech->get_email;
-like $email->body, qr/The following FixMyBarangay reports/, 'Start of email looks correct';
-$mech->clear_emails_ok;
-
-$mech->log_out_ok;
-$mech->get_ok( '/report/' . $luz_report->id );
-$mech->content_lacks( "Remove from site" );
-$mech->content_contains( "Report abuse" );
-
-$mech->post_ok('/report/delete/' . $luz_report->id);
-is $mech->uri->path, '/report/' . $luz_report->id, "should redirect to report page, deletion ignored";
-$luz_report->discard_changes;
-is $luz_report->state, 'confirmed', 'should be confirmed';
-
-$user = $mech->log_in_ok($fmb_test_email);
-
-FixMyStreet::override_config {
- ALLOWED_COBRANDS => [ 'fixmybarangay' ],
-}, sub {
- $mech->get_ok( '/report/' . $luz_report->id );
-};
-$mech->content_contains( "Remove from site" );
-$mech->content_lacks( "Report abuse" );
-
-$mech->form_id('remove-from-site-form');
-$mech->submit_form();
-is $mech->uri->path, '/report/' . $luz_report->id, "should redirect to report page, deletion successful";
-$luz_report->discard_changes;
-is $luz_report->state, 'hidden', 'should be hidden';
-
-$mech->delete_user($fmb_test_email);
-
-$mech->delete_body($luz);
-$mech->delete_body($bsn);
-$mech->delete_body($dps);
-
-ok $mech->host("www.fixmystreet.com"), "change host back";
-
-done_testing();
diff --git a/t/cobrand/form_extras.t b/t/cobrand/form_extras.t
index 9c20b7ad4..c6f6976d5 100644
--- a/t/cobrand/form_extras.t
+++ b/t/cobrand/form_extras.t
@@ -13,7 +13,6 @@ sub path_to_web_templates {
my $self = shift;
return [
FixMyStreet->path_to( 't/cobrand/form_extras/templates' )->stringify,
- FixMyStreet->path_to( 'templates/web/fixmystreet' )->stringify
];
}
diff --git a/t/cobrand/loading.t b/t/cobrand/loading.t
index 48a10293e..b4738fb63 100644
--- a/t/cobrand/loading.t
+++ b/t/cobrand/loading.t
@@ -44,8 +44,8 @@ FixMyStreet::override_config {
}, sub {
run_host_tests(
'www.fixmystreet.com' => 'FixMyStreet',
- 'reportemptyhomes.com' => 'FixMyStreet',
- 'barnet.fixmystreet.com' => 'FixMyStreet',
+ 'fiksgatami.example.org' => 'FixMyStreet',
+ 'oxfordshire.fixmystreet.com' => 'FixMyStreet',
'some.odd.site.com' => 'FixMyStreet',
);
};
@@ -62,49 +62,49 @@ FixMyStreet::override_config {
# Couple of cobrands, hostname checking and default fallback
FixMyStreet::override_config {
- ALLOWED_COBRANDS => [ 'emptyhomes', 'fixmystreet' ],
+ ALLOWED_COBRANDS => [ 'fiksgatami', 'fixmystreet' ],
}, sub {
run_host_tests(
'www.fixmystreet.com' => 'FixMyStreet',
- 'reportemptyhomes.com' => 'EmptyHomes',
- 'barnet.fixmystreet.com' => 'FixMyStreet', # not in the allowed_cobrands list
+ 'fiksgatami.example.org' => 'FiksGataMi',
+ 'oxfordshire.fixmystreet.com' => 'FixMyStreet', # not in the allowed_cobrands list
'some.odd.site.com' => 'Default',
);
};
-# now enable barnet too and check that it works
+# now enable oxfordshire too and check that it works
FixMyStreet::override_config {
- ALLOWED_COBRANDS => [ 'emptyhomes', 'barnet', 'fixmystreet' ],
+ ALLOWED_COBRANDS => [ 'fiksgatami', 'oxfordshire', 'fixmystreet' ],
}, sub {
run_host_tests(
'www.fixmystreet.com' => 'FixMyStreet',
- 'reportemptyhomes.com' => 'EmptyHomes',
- 'barnet.fixmystreet.com' => 'Barnet', # found now it is in allowed_cobrands
+ 'fiksgatami.example.org' => 'FiksGataMi',
+ 'oxfordshire.fixmystreet.com' => 'Oxfordshire', # found now it is in allowed_cobrands
'some.odd.site.com' => 'Default',
);
};
# And a check with some regex matching
FixMyStreet::override_config {
- ALLOWED_COBRANDS => [ { 'fixmystreet' => 'empty' }, 'barnet', { 'testing' => 'fixmystreet' } ],
+ ALLOWED_COBRANDS => [ { 'fixmystreet' => 'example' }, 'oxfordshire', { 'testing' => 'fixmystreet' } ],
}, sub {
run_host_tests(
'www.fixmystreet.com' => 'testing',
- 'reportemptyhomes.com' => 'FixMyStreet',
- 'barnet.fixmystreet.com' => 'Barnet',
+ 'fiksgatami.example.org' => 'FixMyStreet',
+ 'oxfordshire.fixmystreet.com' => 'Oxfordshire',
'some.odd.site.com' => 'Default',
);
};
# check that the moniker works as expected both on class and object.
-is FixMyStreet::Cobrand::EmptyHomes->moniker, 'emptyhomes',
+is FixMyStreet::Cobrand::FiksGataMi->moniker, 'fiksgatami',
'class->moniker works';
-is FixMyStreet::Cobrand::EmptyHomes->new->moniker, 'emptyhomes',
+is FixMyStreet::Cobrand::FiksGataMi->new->moniker, 'fiksgatami',
'object->moniker works';
# check is_default works
ok FixMyStreet::Cobrand::Default->is_default, '::Default is default';
-ok !FixMyStreet::Cobrand::EmptyHomes->is_default, '::Emptyhomes is not default';
+ok !FixMyStreet::Cobrand::FiksGataMi->is_default, '::FiksGataMi is not default';
# all done
done_testing();
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t
index 4734dc837..cf66136e5 100644
--- a/t/cobrand/zurich.t
+++ b/t/cobrand/zurich.t
@@ -661,7 +661,7 @@ subtest "external report triggers email" => sub {
};
$email = $mech->get_email;
my $report_id = $report->id;
- like $email->header('Subject'), qr/Meldung #$report_id/, 'subject looks okay';
+ like Encode::decode('MIME-Header', $email->header('Subject')), qr/Meldung #$report_id/, 'subject looks okay';
like $email->header('To'), qr/test\@example.com/, 'to line looks correct';
like $email->body, qr/$PUBLIC_RESPONSE/, 'public_response was passed on' or die $email->body;
$mech->clear_emails_ok;
@@ -894,6 +894,11 @@ subtest 'email images to external partners' => sub {
my $expected_email_content = path(__FILE__)->parent->child('zurich_attachments.txt')->slurp;
my $REPORT_ID = $report->id;
+ $expected_email_content =~ s{Subject: (.*?)\r?\n}{
+ my $subj = Encode::decode('MIME-Header', $1);
+ $subj =~ s{REPORT_ID}{$REPORT_ID}g;
+ 'Subject: ' . Email::MIME::Encode::mime_encode($subj, "utf-8") . "\n";
+ }eg;
$expected_email_content =~ s{REPORT_ID}{$REPORT_ID}g;
$expected_email_content =~ s{BOUNDARY}{$boundary}g;
my $expected_email = Email::MIME->new($expected_email_content);
diff --git a/t/cobrand/zurich_attachments.txt b/t/cobrand/zurich_attachments.txt
index 4ccc90205..bdc4333bf 100644
--- a/t/cobrand/zurich_attachments.txt
+++ b/t/cobrand/zurich_attachments.txt
@@ -1,40 +1,33 @@
-MIME-Version: 1.0
-Subject: =?iso-8859-1?Q?Z=FCri?= wie neu: Weitergeleitete Meldung #REPORT_ID
-Content-Type: multipart/mixed; boundary="BOUNDARY"
-To: "External Body" <external_body@example.org>
-Content-Transfer-Encoding: 7bit
-From: FixMyStreet <division@example.org>
-
-
---BOUNDARY
-MIME-Version: 1.0
-Subject: =?iso-8859-1?Q?Z=FCri?= wie neu: Weitergeleitete Meldung #REPORT_ID
-Content-Type: text/plain; charset="iso-8859-1"
-To: "External Body" <external_body@example.org>
-Content-Transfer-Encoding: quoted-printable
-From: FixMyStreet <division@example.org>
-
-Gr=FCezi External Body,
-
-=D6ffentliche URL: http://www.example.org/report/REPORT_ID
-
-Bei Fragen zu "Z=FCri wie neu" wenden Sie sich bitte an
-gis-zentrum@zuerich.ch.=
-
-
-
---BOUNDARY
-MIME-Version: 1.0
-Content-Type: image/jpeg; name="REPORT_ID.0.jpeg"
-Content-Disposition: inline; filename="REPORT_ID.0.jpeg"
-Content-Transfer-Encoding: base64
-
-/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAUDBAQEAwUEBAQFBQUGBwwIBwcHBw8LCwkMEQ8SEhEP
-ERETFhwXExQaFRERGCEYGh0dHx8fExciJCIeJBweHx7/2wBDAQUFBQcGBw4ICA4eFBEUHh4eHh4e
-Hh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh7/wAARCABTAAEDAREA
-AhEBAxEB/8QAFwAAAwEAAAAAAAAAAAAAAAAAAAIIB//EAB8QAQAABAcAAAAAAAAAAAAAAAADBAbT
-BxcYVVaUpf/EABcBAQEBAQAAAAAAAAAAAAAAAAAFBgT/xAAgEQEAAAQHAQAAAAAAAAAAAAAAAwQV
-UgECFlNhodGx/9oADAMBAAIRAxEAPwCywAIozyxS5R58tbbujSW33j6zFRj3fGbKbjAGAgAACs9N
-FCbtUfYg2mO1BM25e/V+lQeW3ISo/9k=
-
---BOUNDARY--
+MIME-Version: 1.0
+Subject: =?iso-8859-1?Q?Z=FCri?= wie neu: Weitergeleitete Meldung #REPORT_ID
+Content-Type: multipart/mixed; boundary="BOUNDARY"
+To: "External Body" <external_body@example.org>
+Content-Transfer-Encoding: 7bit
+From: "FixMyStreet" <division@example.org>
+
+
+--BOUNDARY
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: quoted-printable
+
+Gr=C3=BCezi External Body,
+
+=C3=96ffentliche URL: http://www.example.org/report/REPORT_ID
+
+Bei Fragen zu "Z=C3=BCri wie neu" wenden Sie sich bitte an
+gis-zentrum@zuerich.ch.=
+
+--BOUNDARY
+Content-Type: image/jpeg; name="REPORT_ID.0.jpeg"
+Content-Disposition: inline; filename="REPORT_ID.0.jpeg"
+Content-Transfer-Encoding: base64
+
+/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAUDBAQEAwUEBAQFBQUGBwwIBwcHBw8LCwkMEQ8SEhEP
+ERETFhwXExQaFRERGCEYGh0dHx8fExciJCIeJBweHx7/2wBDAQUFBQcGBw4ICA4eFBEUHh4eHh4e
+Hh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh7/wAARCABTAAEDAREA
+AhEBAxEB/8QAFwAAAwEAAAAAAAAAAAAAAAAAAAIIB//EAB8QAQAABAcAAAAAAAAAAAAAAAADBAbT
+BxcYVVaUpf/EABcBAQEBAQAAAAAAAAAAAAAAAAAFBgT/xAAgEQEAAAQHAQAAAAAAAAAAAAAAAwQV
+UgECFlNhodGx/9oADAMBAAIRAxEAPwCywAIozyxS5R58tbbujSW33j6zFRj3fGbKbjAGAgAACs9N
+FCbtUfYg2mO1BM25e/V+lQeW3ISo/9k=
+
+--BOUNDARY--