diff options
author | Struan Donald <struan@exo.org.uk> | 2011-05-13 17:52:15 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2011-05-13 17:52:15 +0100 |
commit | 8dae03ed508f07265727005bbce9570e51c6c33c (patch) | |
tree | 317f3abe8c092af4d8f44b4b7da0696f92cbf8db /t | |
parent | b683026c94f15f6f4b5214820b1446a8ef684658 (diff) |
display correct error messages and test for bad problem ids
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/contact.t | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/t/app/controller/contact.t b/t/app/controller/contact.t index c4bf83613..860ada4ce 100644 --- a/t/app/controller/contact.t +++ b/t/app/controller/contact.t @@ -77,7 +77,9 @@ for my $test ( subject => '', message => '', }, - errors => [ + page_errors => + [ 'There were problems with your report. Please see below.', ], + field_errors => [ 'Please give your name', 'Please give your email', 'Please give a subject', @@ -91,7 +93,9 @@ for my $test ( subject => '', message => '', }, - errors => [ + page_errors => + [ 'There were problems with your report. Please see below.', ], + field_errors => [ 'Please give your name', 'Please give a valid email address', 'Please give a subject', @@ -105,7 +109,9 @@ for my $test ( subject => '', message => '', }, - errors => [ 'Please give a subject', 'Please write a message', ] + page_errors => + [ 'There were problems with your report. Please see below.', ], + field_errors => [ 'Please give a subject', 'Please write a message', ] }, { fields => { @@ -114,7 +120,9 @@ for my $test ( subject => 'A subject', message => '', }, - errors => [ 'Please write a message', ] + page_errors => + [ 'There were problems with your report. Please see below.', ], + field_errors => [ 'Please write a message', ] }, { fields => { @@ -123,7 +131,9 @@ for my $test ( subject => ' ', message => '', }, - errors => [ 'Please give a subject', 'Please write a message', ] + page_errors => + [ 'There were problems with your report. Please see below.', ], + field_errors => [ 'Please give a subject', 'Please write a message', ] }, { fields => { @@ -132,15 +142,33 @@ for my $test ( subject => 'A subject', message => ' ', }, - errors => [ 'Please write a message', ] + page_errors => + [ 'There were problems with your report. Please see below.', ], + field_errors => [ 'Please write a message', ] + }, + { + url => '/contact?id=1', + fields => { + em => 'test@example.com', + name => 'A name', + subject => 'A subject', + message => 'A message', + id => 'invalid', + }, + page_errors => [ 'Illegal ID' ], + field_errors => [] }, - ) { subtest 'check submit page error handling' => sub { - $mech->get_ok('/contact'); + $mech->get_ok( $test->{url} ? $test->{url} : '/contact' ); $mech->submit_form_ok( { with_fields => $test->{fields} } ); - is_deeply $mech->form_errors, $test->{errors}; + is_deeply $mech->page_errors, $test->{page_errors}; + is_deeply $mech->form_errors, $test->{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}; }; } |