diff options
author | Struan Donald <struan@exo.org.uk> | 2012-12-03 15:50:53 +0000 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2012-12-03 17:49:11 +0000 |
commit | 354292a587781c86a24854e9a610cf625f2ca69b (patch) | |
tree | b32c24efbff92694343ca324756230d1fa677baf /t/app | |
parent | d17fadea1c8eaaed02cd82106e93b83fd74515be (diff) |
add option to send email confirming report has been sent to council
Diffstat (limited to 't/app')
-rw-r--r-- | t/app/model/problem.t | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/t/app/model/problem.t b/t/app/model/problem.t index 9aa52c3cf..63204e05c 100644 --- a/t/app/model/problem.t +++ b/t/app/model/problem.t @@ -540,6 +540,53 @@ foreach my $test ( { }; } +subtest 'check can turn on report sent email alerts' => sub { + eval 'use Test::MockModule; 1' or + plan skip_all => 'Skipping tests that rely on Test::MockModule'; + + $mech->clear_emails_ok; + + FixMyStreet::App->model('DB::Problem')->search( + { + whensent => undef + } + )->update( { whensent => \'ms_current_timestamp()' } ); + + $problem->discard_changes; + $problem->update( { + council => 2651, + state => 'confirmed', + confirmed => \'ms_current_timestamp()', + whensent => undef, + category => 'potholes', + name => 'Test User', + cobrand => 'fixmystreet', + } ); + + my $m = new Test::MockModule( + 'FixMyStreet::Cobrand::FixMyStreet' ); + $m->mock( report_sent_confirmation_email => 1 ); + FixMyStreet::App->model('DB::Problem')->send_reports(); + + $mech->email_count_is( 2 ); + my @emails = $mech->get_email; + 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'; + 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'; + + $problem->discard_changes; + ok defined( $problem->whensent ), 'whensent set'; + + $email = $emails[1]; + like $email->header('Subject'), qr/Problem Report Sent/, 'report sent email title correct'; + like $email->body, qr/Your report about/, 'report sent body correct'; +}; + $problem->comments->delete; $problem->delete; $user->delete; |