diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-03-08 14:13:48 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-03-14 15:36:27 +0000 |
commit | 74a7ed654369cb3ebd282c01d4a0de87a646c4ce (patch) | |
tree | 27e5e8090d8a1e3be4e69b9d5344e9fa67ee1b6a /t/app/model/problem.t | |
parent | 7361516252a4d98620f66318cabe75acb3291efb (diff) |
Use sender in From if From and To domains match.
To deal with a recipient mail server not allowing inbound email
using the same domain as an internal domain, e.g.
https://community.mimecast.com/docs/DOC-1419
Diffstat (limited to 't/app/model/problem.t')
-rw-r--r-- | t/app/model/problem.t | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/t/app/model/problem.t b/t/app/model/problem.t index e9ec22b77..6b1be0a76 100644 --- a/t/app/model/problem.t +++ b/t/app/model/problem.t @@ -148,7 +148,7 @@ for my $test ( my $user = FixMyStreet::DB->resultset('User')->find_or_create( { - email => 'system_user@example.com' + email => 'system_user@example.net' } ); @@ -428,7 +428,7 @@ for my $contact ( { }, { body_id => $body_ids{14279}[0], # Ballymoney category => 'Graffiti', - email => 'highways@example.com', + email => 'highways@example.net', }, { confirmed => 0, body_id => $body_ids{2636}, # Isle of Wight @@ -439,7 +439,7 @@ for my $contact ( { } my %common = ( - email => 'system_user@example.com', + email => 'system_user@example.net', name => 'Andrew Smith', ); foreach my $test ( { @@ -505,6 +505,9 @@ foreach my $test ( { body => $body_ids{14279}[0], category => 'Graffiti', longitude => -6.5, + # As Ballmoney contact has same domain as reporter, the From line will + # become a unique reply address and Reply-To will become the reporter + reply_to => 1, }, { %common, desc => 'directs NI correctly, 2', @@ -563,7 +566,12 @@ foreach my $test ( { if ( $test->{ email_count } ) { my $email = $mech->get_email; 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'; + if ($test->{reply_to}) { + is $email->header('Reply-To'), sprintf('"%s" <%s>', $test->{ name }, $test->{ email } ), 'Reply-To line looks correct'; + like $email->header('From'), qr/"$test->{name}" <fms-report-\d+-\w+\@example.org>/, 'from line looks correct'; + } else { + 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'; my $body = $mech->get_text_body_from_email($email); like $body, qr/A user of FixMyStreet/, 'email body looks a bit like a report'; @@ -671,7 +679,7 @@ subtest 'check can turn on report sent email alerts' => sub { my $email = $emails[0]; 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'; + is $email->header('From'), '"Test User" <system_user@example.net>', 'from line looks correct'; like $email->header('Subject'), qr/A Title/, 'subject line 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'; |