aboutsummaryrefslogtreecommitdiffstats
path: root/t/cobrand
diff options
context:
space:
mode:
Diffstat (limited to 't/cobrand')
-rw-r--r--t/cobrand/zurich.t18
-rw-r--r--t/cobrand/zurich_attachments.txt8
2 files changed, 19 insertions, 7 deletions
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t
index 777e9735f..e130ece87 100644
--- a/t/cobrand/zurich.t
+++ b/t/cobrand/zurich.t
@@ -4,6 +4,7 @@
use strict;
use warnings;
use DateTime;
+use Email::MIME;
use Test::More;
use Test::LongString;
use Path::Tiny;
@@ -884,15 +885,26 @@ subtest 'email images to external partners' => sub {
my @emails = $mech->get_email;
my $email_as_string = $mech->get_first_email(@emails);
my ($boundary) = $email_as_string =~ /boundary="([A-Za-z0-9.]*)"/ms;
- my $changes = $email_as_string =~ s{$boundary}{}g;
- is $changes, 4, '4 boundaries'; # header + 3 around the 2x parts (text + 1 image)
+ my $email = Email::MIME->new($email_as_string);
my $expected_email_content = path(__FILE__)->parent->child('zurich_attachments.txt')->slurp;
my $REPORT_ID = $report->id;
$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);
- is_string $email_as_string, $expected_email_content, 'MIME email text ok'
+ my @email_parts;
+ $email->walk_parts(sub {
+ my ($part) = @_;
+ push @email_parts, [ { $part->header_pairs }, $part->body ];
+ });
+ my @expected_email_parts;
+ $expected_email->walk_parts(sub {
+ my ($part) = @_;
+ push @expected_email_parts, [ { $part->header_pairs }, $part->body ];
+ });
+ is_deeply \@email_parts, \@expected_email_parts, 'MIME email text ok'
or do {
(my $test_name = $0) =~ s{/}{_}g;
my $path = path("test-output-$test_name.tmp");
diff --git a/t/cobrand/zurich_attachments.txt b/t/cobrand/zurich_attachments.txt
index 1c989c4d9..4ccc90205 100644
--- a/t/cobrand/zurich_attachments.txt
+++ b/t/cobrand/zurich_attachments.txt
@@ -1,12 +1,12 @@
MIME-Version: 1.0
Subject: =?iso-8859-1?Q?Z=FCri?= wie neu: Weitergeleitete Meldung #REPORT_ID
-Content-Type: multipart/mixed; boundary=""
+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"
@@ -23,7 +23,7 @@ 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"
@@ -37,4 +37,4 @@ BxcYVVaUpf/EABcBAQEBAQAAAAAAAAAAAAAAAAAFBgT/xAAgEQEAAAQHAQAAAAAAAAAAAAAAAwQV
UgECFlNhodGx/9oADAMBAAIRAxEAPwCywAIozyxS5R58tbbujSW33j6zFRj3fGbKbjAGAgAACs9N
FCbtUfYg2mO1BM25e/V+lQeW3ISo/9k=
-----
+--BOUNDARY--