diff options
author | Struan Donald <struan@exo.org.uk> | 2011-05-25 17:44:37 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2011-05-25 17:44:37 +0100 |
commit | 09a64afec4e023a184de075df3780c8b525b6066 (patch) | |
tree | cad6484a2c8d074251960cd781139d28e68bb2ef /t/app | |
parent | bbe4d5975fddfc731b0177119bf4cda401d41d97 (diff) |
use c->send_email on contact page and add more tests
Diffstat (limited to 't/app')
-rw-r--r-- | t/app/controller/contact.t | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/t/app/controller/contact.t b/t/app/controller/contact.t index 860ada4ce..fbf794b6b 100644 --- a/t/app/controller/contact.t +++ b/t/app/controller/contact.t @@ -163,13 +163,13 @@ for my $test ( subtest 'check submit page error handling' => sub { $mech->get_ok( $test->{url} ? $test->{url} : '/contact' ); $mech->submit_form_ok( { with_fields => $test->{fields} } ); - is_deeply $mech->page_errors, $test->{page_errors}; - is_deeply $mech->form_errors, $test->{field_errors}; + is_deeply $mech->page_errors, $test->{page_errors}, 'page errors'; + is_deeply $mech->form_errors, $test->{field_errors}, 'field_errors'; # we santise this when we submit so need to remove it delete $test->{fields}->{id} if $test->{fields}->{id} and $test->{fields}->{id} eq 'invalid'; - is_deeply $mech->visible_form_values, $test->{fields}; + is_deeply $mech->visible_form_values, $test->{fields}, 'form values'; }; } @@ -186,9 +186,18 @@ for my $test ( ) { subtest 'check email sent correctly' => sub { + $mech->clear_emails_ok; $mech->get_ok('/contact'); $mech->submit_form_ok( { with_fields => $test->{fields} } ); $mech->content_contains('Thanks for your feedback'); + $mech->email_count_is(1); + + my $email = $mech->get_email; + + is $email->header('Subject'), 'FMS message: ' . $test->{fields}->{subject}, 'subject'; + is $email->header('From'), "\"$test->{fields}->{name}\" <$test->{fields}->{em}>", 'from'; + like $email->body, qr/$test->{fields}->{message}/, 'body'; + like $email->body, qr/Sent by contact.cgi on \S+. IP address (?:\d{1,3}\.){3,}\d{1,3}/, 'body footer' }; } done_testing(); |