aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/model
diff options
context:
space:
mode:
Diffstat (limited to 't/app/model')
-rw-r--r--t/app/model/alert_type.t18
-rw-r--r--t/app/model/problem.t27
2 files changed, 21 insertions, 24 deletions
diff --git a/t/app/model/alert_type.t b/t/app/model/alert_type.t
index e94ee8ce1..4e8817225 100644
--- a/t/app/model/alert_type.t
+++ b/t/app/model/alert_type.t
@@ -145,7 +145,7 @@ for my $test (
my @emails = $mech->get_email;
my $msg = $test->{msg};
for my $email (@emails) {
- my $body = $email->body;
+ my $body = $mech->get_text_body_from_email($email);
my $to = $email->header('To');
like $body, qr/$msg/, 'email says problem is ' . $test->{state};
@@ -193,9 +193,8 @@ subtest "correct text for title after URL" => sub {
FixMyStreet::DB->resultset('AlertType')->email_alerts();
};
- my $email = $mech->get_email;
(my $title = $report->title) =~ s/ /\\s+/;
- my $body = $email->body;
+ my $body = $mech->get_text_body_from_email;
like $body, qr#report/$report_id\s+-\s+$title#, 'email contains expected title';
};
@@ -330,8 +329,7 @@ foreach my $test (
FixMyStreet::DB->resultset('AlertType')->email_alerts();
};
- my $email = $mech->get_email;
- my $body = $email->body;
+ my $body = $mech->get_text_body_from_email;
if ( $test->{nearest} ) {
like $body, $test->{nearest}, 'correct nearest line';
@@ -439,8 +437,7 @@ subtest "check alerts from cobrand send main site url for alerts for different c
FixMyStreet::DB->resultset('AlertType')->email_alerts();
};
- my $email = $mech->get_email;
- my $body = $email->body;
+ 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;
@@ -476,8 +473,7 @@ subtest "check local alerts from cobrand send main site url for alerts for diffe
FixMyStreet::DB->resultset('AlertType')->email_alerts();
- my $email = $mech->get_email;
- my $body = $email->body;
+ my $body = $mech->get_text_body_from_email;
my $expected1 = FixMyStreet->config('BASE_URL') . '/report/' . $report_to_county_council->id;
my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker('hart')->new();
@@ -505,9 +501,7 @@ subtest "correct i18n-ed summary for state of closed" => sub {
FixMyStreet::DB->resultset('AlertType')->email_alerts();
};
- $mech->email_count_is( 1 );
- my $email = $mech->get_email;
- my $body = $email->body;
+ my $body = $mech->get_text_body_from_email;
my $msg = 'Denne rapporten er for tiden markert som lukket';
like $body, qr/$msg/, 'email says problem is closed, in Norwegian';
};
diff --git a/t/app/model/problem.t b/t/app/model/problem.t
index ea45f7356..836e8a047 100644
--- a/t/app/model/problem.t
+++ b/t/app/model/problem.t
@@ -548,24 +548,25 @@ foreach my $test ( {
like $email->header('To'), $test->{ to }, 'to line looks correct';
is $email->header('From'), sprintf('"%s" <%s>', $test->{ name }, $test->{ email } ), 'from line looks correct';
like $email->header('Subject'), qr/A Title/, 'subject line looks correct';
- like $email->body, qr/A user of FixMyStreet/, 'email body looks a bit like a report';
- like $email->body, qr/Subject: A Title/, 'more email body checking';
- like $email->body, $test->{ dear }, 'Salutation looks correct';
+ my $body = $mech->get_text_body_from_email($email);
+ like $body, qr/A user of FixMyStreet/, 'email body looks a bit like a report';
+ like $body, qr/Subject: A Title/, 'more email body checking';
+ like $body, $test->{ dear }, 'Salutation looks correct';
if ($test->{longitude}) {
- like $email->body, qr{Easting/Northing \(IE\): 297279/362371};
+ like $body, qr{Easting/Northing \(IE\): 297279/362371};
} else {
- like $email->body, qr{Easting/Northing: };
+ like $body, qr{Easting/Northing: };
}
if ( $test->{multiple} ) {
- like $email->body, qr/This email has been sent to several councils /, 'multiple body text correct';
+ like $body, qr/This email has been sent to several councils /, 'multiple body text correct';
} elsif ( $test->{ missing } ) {
- like $email->body, $test->{ missing }, 'missing body information correct';
+ like $body, $test->{ missing }, 'missing body information correct';
}
if ( $test->{url} ) {
my $id = $problem->id;
- like $email->body, qr[$test->{url}fixmystreet.com/report/$id], 'URL present is correct';
+ like $body, qr[$test->{url}fixmystreet.com/report/$id], 'URL present is correct';
}
$problem->discard_changes;
@@ -655,16 +656,18 @@ subtest 'check can turn on report sent email alerts' => sub {
like $email->header('To'),qr/City of Edinburgh Council/, 'to line looks correct';
is $email->header('From'), '"Test User" <system_user@example.com>', 'from line looks correct';
like $email->header('Subject'), qr/A Title/, 'subject line looks correct';
- like $email->body, qr/A user of FixMyStreet/, 'email body looks a bit like a report';
- like $email->body, qr/Subject: A Title/, 'more email body checking';
- like $email->body, qr/Dear City of Edinburgh Council/, 'Salutation looks correct';
+ my $body = $mech->get_text_body_from_email($email);
+ like $body, qr/A user of FixMyStreet/, 'email body looks a bit like a report';
+ like $body, qr/Subject: A Title/, 'more email body checking';
+ like $body, qr/Dear City of Edinburgh Council/, 'Salutation looks correct';
$problem->discard_changes;
ok defined( $problem->whensent ), 'whensent set';
$email = $emails[1];
like $email->header('Subject'), qr/FixMyStreet Report Sent/, 'report sent email title correct';
- like $email->body, qr/to submit your report/, 'report sent body correct';
+ $body = $mech->get_text_body_from_email($email);
+ like $body, qr/to submit your report/, 'report sent body correct';
$send_confirmation_mail_override->restore();
};