diff options
Diffstat (limited to 't/app/controller')
-rw-r--r-- | t/app/controller/report_new_text.t | 49 |
1 files changed, 36 insertions, 13 deletions
diff --git a/t/app/controller/report_new_text.t b/t/app/controller/report_new_text.t index 852cdac76..9256a00de 100644 --- a/t/app/controller/report_new_text.t +++ b/t/app/controller/report_new_text.t @@ -15,17 +15,43 @@ $mech->create_contact_ok( body_id => $body->id, category => 'Street lighting', e $mech->create_contact_ok( body_id => $body->id, category => 'Trees', email => 'trees@example.com' ); # test that phone number validation works okay +my %defaults = ( + title => 'Title', detail => 'Detail', name => 'Bob Jones', + category => 'Street lighting', may_show_name => 1, + photo1 => '', photo2 => '', photo3 => '', + password_register => '', password_sign_in => '', +); foreach my $test ( { + msg => 'missing update method', + pc => 'EH1 1BB', + fields => { + update_method => undef, phone => '', email => '', + %defaults, + }, + changes => { + username => '', + }, + errors => [ 'Please enter your email', 'Please pick your update preference' ], + }, + { + msg => 'email method', + pc => 'EH1 1BB', + fields => { + update_method => 'email', phone => '', email => 'bademail', + %defaults, + }, + changes => { + username => 'bademail', + }, + errors => [ 'Please enter a valid email' ], + }, + { msg => 'invalid number', pc => 'EH1 1BB', fields => { - username => '0121 4960000000', email => '', phone => '', - title => 'Title', detail => 'Detail', name => 'Bob Jones', - category => 'Street lighting', - may_show_name => '1', - photo1 => '', photo2 => '', photo3 => '', - password_register => '', password_sign_in => '', + update_method => 'phone', phone => '0121 4960000000', email => '', + %defaults, }, changes => { username => '01214960000000', @@ -37,12 +63,8 @@ foreach my $test ( msg => 'landline number', pc => 'EH1 1BB', fields => { - username => '0121 4960000', email => '', phone => '', - title => 'Title', detail => 'Detail', name => 'Bob Jones', - category => 'Street lighting', - may_show_name => '1', - photo1 => '', photo2 => '', photo3 => '', - password_register => '', password_sign_in => '', + update_method => 'phone', phone => '0121 4960000', email => '', + %defaults, }, changes => { username => '0121 496 0000', @@ -142,7 +164,8 @@ foreach my $test ( title => 'Test Report', detail => 'Test report details.', photo1 => '', name => 'Joe Bloggs', may_show_name => '1', - username => $test_phone, + update_method => 'phone', + phone => $test_phone, category => 'Street lighting', password_register => $test->{password} ? 'secret' : '', } |