diff options
Diffstat (limited to 't/app/controller')
-rw-r--r-- | t/app/controller/auth_social.t | 6 | ||||
-rw-r--r-- | t/app/controller/contact_enquiry.t | 6 | ||||
-rw-r--r-- | t/app/controller/report_display.t | 2 | ||||
-rw-r--r-- | t/app/controller/report_import.t | 2 | ||||
-rw-r--r-- | t/app/controller/report_new.t | 10 | ||||
-rw-r--r-- | t/app/controller/report_new_errors.t | 76 | ||||
-rw-r--r-- | t/app/controller/report_new_open311.t | 15 | ||||
-rw-r--r-- | t/app/controller/report_new_text.t | 67 | ||||
-rw-r--r-- | t/app/controller/report_new_unresponsive.t | 2 | ||||
-rw-r--r-- | t/app/controller/report_update_text.t | 63 | ||||
-rw-r--r-- | t/app/controller/report_updates.t | 64 |
11 files changed, 208 insertions, 105 deletions
diff --git a/t/app/controller/auth_social.t b/t/app/controller/auth_social.t index 1f6889dcc..9d1ea836f 100644 --- a/t/app/controller/auth_social.t +++ b/t/app/controller/auth_social.t @@ -241,7 +241,8 @@ for my $state ( 'refused', 'no email', 'existing UID', 'okay' ) { $mech->content_contains('We need your email address, please give it below.'); # We don't have an email, so check that we can still submit it, # and the ID carries through the confirmation - $fields->{username} = $test->{email}; + $fields->{username} = $test->{email} if $page eq 'my'; + $fields->{username_register} = $test->{email} unless $page eq 'my'; $fields->{name} = 'Ffion Tester' unless $page eq 'my'; $mech->submit_form(with_fields => $fields, $page eq 'my' ? (button => 'sign_in_by_code') : ()); $mech->content_contains('Nearly done! Now check your email'); @@ -408,7 +409,8 @@ for my $tw_state ( 'refused', 'existing UID', 'no email' ) { $mech->content_contains('We need your email address, please give it below.'); # We don't have an email, so check that we can still submit it, # and the ID carries through the confirmation - $fields->{username} = $tw_email; + $fields->{username_register} = $tw_email unless $page eq 'my'; + $fields->{username} = $tw_email if $page eq 'my'; $fields->{name} = 'Ffion Tester' unless $page eq 'my'; $mech->submit_form(with_fields => $fields, $page eq 'my' ? (button => 'sign_in_by_code') : ()); $mech->content_contains('Nearly done! Now check your email'); diff --git a/t/app/controller/contact_enquiry.t b/t/app/controller/contact_enquiry.t index feb2a0545..f1b5b15cd 100644 --- a/t/app/controller/contact_enquiry.t +++ b/t/app/controller/contact_enquiry.t @@ -80,7 +80,7 @@ FixMyStreet::override_config { $mech->submit_form_ok( { with_fields => { name => 'Test User', - username => 'testuser@example.org', + username_register => 'testuser@example.org', category => 'Other', detail => 'This is a general enquiry', } @@ -149,7 +149,7 @@ FixMyStreet::override_config { $mech->submit_form_ok( { with_fields => { name => 'Simon Neil', - username => $user->email, + username_register => $user->email, category => 'General Enquiry', detail => 'This is a general enquiry', } @@ -212,7 +212,7 @@ FixMyStreet::override_config { submit_problem => 1, token => $csrf, name => 'Test User', - username => 'testuser@example.org', + username_register => 'testuser@example.org', category => 'Other', detail => encode_utf8('This is a general enquiry‽'), photo1 => [ $sample_jpeg, undef, Content_Type => 'image/jpeg' ], diff --git a/t/app/controller/report_display.t b/t/app/controller/report_display.t index 4bd0fc991..00c7bf19b 100644 --- a/t/app/controller/report_display.t +++ b/t/app/controller/report_display.t @@ -109,7 +109,7 @@ subtest "test a good report" => sub { my %fields = ( name => '', - username => '', + username_register => '', update => '', add_alert => 1, # defaults to true fixed => undef diff --git a/t/app/controller/report_import.t b/t/app/controller/report_import.t index b2e15330a..7b5ede7a9 100644 --- a/t/app/controller/report_import.t +++ b/t/app/controller/report_import.t @@ -376,7 +376,7 @@ subtest "Submit a correct entry (with location) to cobrand" => sub { photo2 => '', photo3 => '', phone => '', - username => 'test-ll@example.com', + username_register => 'test-ll@example.com', }, "check imported fields are shown" or diag Dumper( $mech->visible_form_values ); use Data::Dumper; diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t index 6af709c2c..b0c93c332 100644 --- a/t/app/controller/report_new.t +++ b/t/app/controller/report_new.t @@ -156,7 +156,7 @@ foreach my $test ( photo1 => '', name => 'Joe Bloggs', may_show_name => '1', - username => 'test-1@example.com', + username_register => 'test-1@example.com', phone => '07903 123 456', category => 'Street lighting', password_register => $test->{password} ? 'secret' : '', @@ -680,7 +680,7 @@ subtest "test report creation for a category that is non public" => sub { title => 'Test Report', detail => 'Test report details.', photo1 => '', - username => $user->email, + username_register => $user->email, name => 'Joe Bloggs', category => 'Street lighting', } @@ -940,7 +940,7 @@ for my $test ( title => "Test Report", detail => 'Test report details.', photo1 => '', - username => 'firstlast@example.com', + username_register => 'firstlast@example.com', may_show_name => '1', phone => '07903 123 456', category => 'Trees', @@ -1085,7 +1085,7 @@ subtest "test Hart" => sub { $mech->submit_form_ok( { with_fields => { pc => 'GU51 4AE' } }, "submit location" ); $mech->follow_link_ok( { text_regex => qr/skip this step/i, }, "follow 'skip this step' link" ); my %optional_fields = $test->{confirm} ? () : - ( username => $test_email, phone => '07903 123 456' ); + ( username_register => $test_email, phone => '07903 123 456' ); # we do this as otherwise test::www::mechanize::catalyst # goes to the value set in ->host above irregardless and @@ -1279,7 +1279,7 @@ subtest "extra google analytics code displayed on email confirmation problem cre title => "Test Report", detail => 'Test report details.', photo1 => '', - username => 'firstlast@example.com', + username_register => 'firstlast@example.com', name => 'Test User', may_show_name => '1', phone => '07903 123 456', diff --git a/t/app/controller/report_new_errors.t b/t/app/controller/report_new_errors.t index f45f13c1e..470cb7d79 100644 --- a/t/app/controller/report_new_errors.t +++ b/t/app/controller/report_new_errors.t @@ -112,6 +112,7 @@ foreach my $test ( photo3 => '', name => '', may_show_name => '1', + username_register => '', username => '', phone => '', password_sign_in => '', @@ -137,6 +138,7 @@ foreach my $test ( photo3 => '', name => '', may_show_name => '1', + username_register => '', username => '', phone => '', category => 'Something bad', @@ -165,6 +167,7 @@ foreach my $test ( photo3 => '', name => '', may_show_name => '1', + username_register => '', username => '', phone => '', category => 'Street lighting', @@ -190,6 +193,7 @@ foreach my $test ( photo3 => '', name => '', may_show_name => undef, + username_register => '', username => '', phone => '', category => 'Street lighting', @@ -215,6 +219,7 @@ foreach my $test ( photo3 => '', name => 'Bob Jones', may_show_name => undef, + username_register => '', username => '', phone => '', category => 'Street lighting', @@ -239,6 +244,7 @@ foreach my $test ( photo3 => '', name => 'Bob Jones', may_show_name => '1', + username_register => '', username => '', phone => '', category => 'Street lighting', @@ -263,6 +269,7 @@ foreach my $test ( photo3 => '', name => 'Bob Jones', may_show_name => '1', + username_register => '', username => '', phone => '', category => 'Street lighting', @@ -287,6 +294,7 @@ foreach my $test ( photo3 => '', name => 'DUDE', may_show_name => '1', + username_register => '', username => '', phone => '', category => 'Street lighting', @@ -310,6 +318,7 @@ foreach my $test ( photo3 => '', name => 'anonymous', may_show_name => '1', + username_register => '', username => '', phone => '', category => 'Street lighting', @@ -333,13 +342,14 @@ foreach my $test ( photo3 => '', name => 'Joe Smith', may_show_name => '1', - username => 'not an email', + username_register => 'not an email', + username => '', phone => '', category => 'Street lighting', password_sign_in => '', password_register => '', }, - changes => { username => 'notanemail' }, + changes => {}, errors => [ 'Please enter a valid email', ], }, { @@ -353,6 +363,7 @@ foreach my $test ( photo3 => '', name => '', may_show_name => '1', + username_register => '', username => '', phone => '', category => 'Street lighting', @@ -379,7 +390,8 @@ foreach my $test ( photo3 => '', name => ' Bob Jones ', may_show_name => '1', - username => ' BOB @ExAmplE.COM ', + username_register => ' BOB @ExAmplE.COM ', + username => '', phone => '', category => 'Street lighting', password_sign_in => '', @@ -387,7 +399,6 @@ foreach my $test ( }, changes => { name => 'Bob Jones', - username => 'bob@example.com', }, errors => [ 'Please enter a subject', 'Please enter some details', ], }, @@ -402,7 +413,8 @@ foreach my $test ( photo3 => '', name => 'Bob Jones', may_show_name => '1', - username => 'bob@example.com', + username_register => 'bob@example.com', + username => '', phone => '', category => 'Street lighting', password_sign_in => '', @@ -424,7 +436,8 @@ foreach my $test ( photo3 => '', name => 'Bob Jones', may_show_name => '1', - username => 'bob@example.com', + username_register => 'bob@example.com', + username => '', phone => '', category => 'Street lighting', password_sign_in => '', @@ -446,7 +459,8 @@ foreach my $test ( photo3 => '', name => 'Bob Jones', may_show_name => '1', - username => 'bob@example.com', + username_register => 'bob@example.com', + username => '', phone => '', category => 'Street lighting', password_sign_in => '', @@ -468,14 +482,14 @@ foreach my $test ( photo3 => '', name => 'Joe Smith', may_show_name => '1', - username => 'user@example.com', + username_register => 'user@example.com', + username => '', phone => '', category => 'Street lighting', password_sign_in => '', password_register => '', }, changes => { - username => 'user@example.com', title => 'User@example.com' }, errors => [ 'Please make sure you are not including an email address', ], @@ -492,7 +506,8 @@ foreach my $test ( photo3 => '', name => 'Bob Example', may_show_name => '1', - username => 'bob@example.com', + username_register => 'bob@example.com', + username => '', phone => '', category => 'Trees', password_sign_in => '', @@ -512,7 +527,8 @@ foreach my $test ( photo3 => '', name => 'Bob Example', may_show_name => '1', - username => 'bob@example.com', + username_register => 'bob@example.com', + username => '', phone => '', category => 'Trees', password_sign_in => '', @@ -532,7 +548,8 @@ foreach my $test ( photo3 => '', name => 'Bob Example', may_show_name => '1', - username => 'bob@example.com', + username_register => 'bob@example.com', + username => '', phone => '123456789 12345678910', category => 'Trees', password_sign_in => '', @@ -552,7 +569,8 @@ foreach my $test ( photo3 => '', name => 'This is a very long name that should fail validation', may_show_name => '1', - username => 'bob@example.com', + username_register => 'bob@example.com', + username => '', phone => '', category => 'Street lighting', password_sign_in => '', @@ -572,7 +590,8 @@ foreach my $test ( photo3 => '', name => 'This is a very long name that should fail validation', may_show_name => '1', - username => 'bob@example.com', + username_register => 'bob@example.com', + username => '', phone => '', category => 'Trees', password_sign_in => '', @@ -592,7 +611,8 @@ foreach my $test ( photo3 => '', name => 'This is a really extraordinarily long name that definitely should fail validation', may_show_name => '1', - username => 'bob.has.a.very.long.email@thisisalonghostname.example.com', + username_register => 'bob.has.a.very.long.email@thisisalonghostname.example.com', + username => '', phone => '01234 5678910 09876 54321 ext 203', category => 'Trees', password_sign_in => '', @@ -612,7 +632,8 @@ foreach my $test ( photo3 => '', name => 'A User', may_show_name => '1', - username => 'user@example.org', + username_register => 'user@example.org', + username => '', phone => '', category => 'Trees', password_sign_in => '', @@ -632,7 +653,8 @@ foreach my $test ( photo3 => '', name => 'A User', may_show_name => '1', - username => 'user@example.org', + username_register => 'user@example.org', + username => '', phone => '', category => 'Trees', password_sign_in => '', @@ -702,6 +724,26 @@ subtest "test password errors for a user who is signing in as they report" => su title => 'Test Report', detail => 'Test report details.', photo1 => '', + username => 'test-2', + password_sign_in => 'secret1', + category => 'Street lighting', + } + }, + "submit with wrong password" + ); + + is_deeply $mech->page_errors, [ + "Please enter a valid email", + "There was a problem with your login information. If you cannot remember your password, or do not have one, please fill in the \x{2018}No\x{2019} section of the form.", + ], "check there were errors"; + + $mech->submit_form_ok( + { + button => 'submit_sign_in', + with_fields => { + title => 'Test Report', + detail => 'Test report details.', + photo1 => '', username => 'test-2@example.com', password_sign_in => 'secret1', category => 'Street lighting', diff --git a/t/app/controller/report_new_open311.t b/t/app/controller/report_new_open311.t index 7cd6dca09..ebbb06567 100644 --- a/t/app/controller/report_new_open311.t +++ b/t/app/controller/report_new_open311.t @@ -108,7 +108,8 @@ my $empty_form = { photo3 => '', name => '', may_show_name => '1', - username => '', + username_register => '', + username => '', phone => '', category => '', password_sign_in => '', @@ -130,14 +131,14 @@ foreach my $test ( 'This information is required', 'Please enter a subject', 'Please enter some details', - 'Please enter your email', 'Please enter your name', + 'Please enter your email', ], submit_with => { title => 'test', detail => 'test detail', name => 'Test User', - username => 'testopen311@example.com', + username_register => 'testopen311@example.com', category => 'Street lighting', number => 27, type => 'old', @@ -170,14 +171,14 @@ foreach my $test ( 'This information is required', 'Please enter a subject', 'Please enter some details', - 'Please enter your email', 'Please enter your name', + 'Please enter your email', ], submit_with => { title => 'test', detail => 'test detail', name => 'Test User', - username => 'testopen311@example.com', + username_register => 'testopen311@example.com', size => 'big', colour => 'red', }, @@ -201,7 +202,7 @@ foreach my $test ( $mech->clear_emails_ok; # check that the user does not exist - my $test_email = $test->{submit_with}->{username}; + my $test_email = $test->{submit_with}->{username_register}; my $user = FixMyStreet::DB->resultset('User')->find( { email => $test_email } ); if ( $user ) { $user->problems->delete; @@ -452,7 +453,7 @@ subtest "Category extras includes form disabling string" => sub { # Test submission of whole form, switching back to a blocked category at the same time $mech->submit_form_ok({ with_fields => { category => 'Pothole', title => 'Title', detail => 'Detail', - username => 'testing@example.org', name => 'Testing Example', + username_register => 'testing@example.org', name => 'Testing Example', } }); $mech->content_contains('<div id="js-category-stopper" class="box-warning" role="alert" aria-live="assertive">'); $mech->content_contains('Please ring us!'); diff --git a/t/app/controller/report_new_text.t b/t/app/controller/report_new_text.t index 852cdac76..fa012c6ae 100644 --- a/t/app/controller/report_new_text.t +++ b/t/app/controller/report_new_text.t @@ -15,20 +15,46 @@ $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 => '', + }, + 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', + username => '', phone => '01214960000000', }, errors => [ 'Please check your phone number is correct' ], @@ -37,19 +63,28 @@ 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', + username => '', phone => '0121 496 0000', }, errors => [ 'Please enter a mobile number', ], }, + { + msg => 'number that fails', + pc => 'EH1 1BB', + fields => { + update_method => 'phone', phone => '+18165550101', email => '', + %defaults, + }, + changes => { + username => '', + phone => '+1 816-555-0101', + }, + errors => [ 'Sending a confirmation text failed: "Unable to send (21408)"' ], + }, ) { subtest "check form errors where $test->{msg}" => sub { @@ -60,6 +95,7 @@ foreach my $test ( MAPIT_URL => 'http://mapit.uk/', SMS_AUTHENTICATION => 1, PHONE_COUNTRY => 'GB', + TWILIO_ACCOUNT_SID => 'AC123', }, sub { $mech->submit_form_ok( { with_fields => { pc => $test->{pc} } }, "submit location" ); @@ -142,7 +178,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' : '', } diff --git a/t/app/controller/report_new_unresponsive.t b/t/app/controller/report_new_unresponsive.t index 033475c25..211f7198d 100644 --- a/t/app/controller/report_new_unresponsive.t +++ b/t/app/controller/report_new_unresponsive.t @@ -107,7 +107,7 @@ sub make_report { detail => 'Test report details.', photo1 => '', name => 'Joe Bloggs', - username => $user->email, + username_register => $user->email, may_show_name => '1', phone => '07903 123 456', category => 'Trees', diff --git a/t/app/controller/report_update_text.t b/t/app/controller/report_update_text.t index 52f221264..fbf5ca0c6 100644 --- a/t/app/controller/report_update_text.t +++ b/t/app/controller/report_update_text.t @@ -58,21 +58,25 @@ my $comment = FixMyStreet::DB->resultset('Comment')->find_or_create( { my $comment_id = $comment->id; ok $comment, "created test update - $comment_id"; +my %defaults = ( + username => '', + update => 'Update', + name => 'Name', + photo1 => '', + photo2 => '', + photo3 => '', + fixed => undef, + add_alert => 1, + may_show_name => undef, + password_sign_in => '', + password_register => '', +); for my $test ( { desc => 'Invalid phone', fields => { - username => '01214960000000', - update => 'Update', - name => 'Name', - photo1 => '', - photo2 => '', - photo3 => '', - fixed => undef, - add_alert => 1, - may_show_name => undef, - password_sign_in => '', - password_register => '', + username_register => '01214960000000', + %defaults, }, changes => {}, field_errors => [ 'Please check your phone number is correct' ] @@ -80,23 +84,21 @@ for my $test ( { desc => 'landline number', fields => { - username => '01214960000', - update => 'Update', - name => 'Name', - photo1 => '', - photo2 => '', - photo3 => '', - fixed => undef, - add_alert => 1, - may_show_name => undef, - password_register => '', - password_sign_in => '', - }, - changes => { - username => '0121 496 0000', + username_register => '01214960000', + %defaults, }, + changes => {}, field_errors => [ 'Please enter a mobile number' ] }, + { + desc => 'fails to send', + fields => { + username_register => '+18165550101', + %defaults, + }, + changes => {}, + field_errors => [ 'Sending a confirmation text failed: "Unable to send (21408)"' ] + }, ) { subtest "submit an update - $test->{desc}" => sub { @@ -104,6 +106,7 @@ for my $test ( FixMyStreet::override_config { SMS_AUTHENTICATION => 1, + TWILIO_ACCOUNT_SID => 'AC123', PHONE_COUNTRY => 'GB', }, sub { $mech->submit_form_ok( { with_fields => $test->{fields} }, 'submit update' ); @@ -126,7 +129,7 @@ for my $test ( desc => 'submit an update, unregistered, logged out', form_values => { submit_update => 1, - username => $test_phone, + username_register => $test_phone, update => 'Update from an unregistered user', add_alert => undef, name => 'Unreg User', @@ -137,7 +140,7 @@ for my $test ( desc => 'submit an update, unregistered, logged out, sign up for alerts', form_values => { submit_update => 1, - username => $test_phone, + username_register => $test_phone, update => 'Update from an unregistered user', add_alert => 1, name => 'Unreg User', @@ -149,7 +152,7 @@ for my $test ( registered => 1, form_values => { submit_update => 1, - username => $test_phone, + username_register => $test_phone, update => 'Update from a registered user', add_alert => undef, name => 'Reg User', @@ -194,7 +197,7 @@ for my $test ( ok $update, 'found update in database'; is $update->state, 'unconfirmed', 'update unconfirmed'; my $details = $test->{form_values}; - is $update->user->phone, $details->{username}, 'update phone'; + is $update->user->phone, $details->{username_register}, 'update phone'; is $update->user->phone_verified, 1; is $update->text, $details->{update}, 'update text'; is $add_alerts, $details->{add_alert} ? 1 : 0, 'do not sign up for alerts'; @@ -211,7 +214,7 @@ for my $test ( ok $user->check_password( 'new_secret' ), 'password changed'; is $user->name, 'Reg User', 'name changed'; } else { - $user = FixMyStreet::DB->resultset( 'User' )->find( { phone => $details->{username} } ); + $user = FixMyStreet::DB->resultset( 'User' )->find( { phone => $details->{username_register} } ); ok $user, 'found user'; } diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t index 92cbed861..760a5a45b 100644 --- a/t/app/controller/report_updates.t +++ b/t/app/controller/report_updates.t @@ -272,7 +272,8 @@ for my $test ( { desc => 'No email, no message', fields => { - username => '', + username_register => '', + username => '', update => '', name => '', photo1 => '', @@ -285,12 +286,13 @@ for my $test ( password_sign_in => '', }, changes => {}, - field_errors => [ 'Please enter a message', 'Please enter your email', 'Please enter your name' ] + field_errors => [ 'Please enter a message', 'Please enter your name', 'Please enter your email' ] }, { desc => 'Invalid email, no message', fields => { - username => 'test', + username_register => 'test', + username => '', update => '', name => '', photo1 => '', @@ -303,12 +305,13 @@ for my $test ( password_register => '', }, changes => {}, - field_errors => [ 'Please enter a message', 'Please enter a valid email', 'Please enter your name' ] + field_errors => [ 'Please enter a message', 'Please enter your name', 'Please enter a valid email' ] }, { desc => 'email with spaces, no message', fields => { - username => 'test @ example. com', + username_register => 'test @ example. com', + username => '', update => '', name => '', photo1 => '', @@ -320,15 +323,14 @@ for my $test ( password_register => '', password_sign_in => '', }, - changes => { - username => 'test@example.com', - }, + changes => {}, field_errors => [ 'Please enter a message', 'Please enter your name' ] }, { desc => 'email with uppercase, no message', fields => { - username => 'test@EXAMPLE.COM', + username_register => 'test@EXAMPLE.COM', + username => '', update => '', name => '', photo1 => '', @@ -340,9 +342,7 @@ for my $test ( password_register => '', password_sign_in => '', }, - changes => { - username => 'test@example.com', - }, + changes => {}, field_errors => [ 'Please enter a message', 'Please enter your name' ] }, ) @@ -369,6 +369,7 @@ for my $test ( desc => 'submit an update for a non registered user', initial_values => { name => '', + username_register => '', username => '', may_show_name => undef, add_alert => 1, @@ -382,7 +383,7 @@ for my $test ( }, form_values => { submit_update => 1, - username => 'unregistered@example.com', + username_register => 'unregistered@example.com', update => 'Update from an unregistered user', add_alert => undef, name => 'Unreg User', @@ -394,6 +395,7 @@ for my $test ( desc => 'submit an update for a non registered user and sign up', initial_values => { name => '', + username_register => '', username => '', may_show_name => undef, add_alert => 1, @@ -407,7 +409,7 @@ for my $test ( }, form_values => { submit_update => 1, - username => 'unregistered@example.com', + username_register => 'unregistered@example.com', update => "update from an\r\n\r\nunregistered user", add_alert => 1, name => 'Unreg User', @@ -465,14 +467,14 @@ for my $test ( ok $update, 'found update in database'; is $update->state, 'unconfirmed', 'update unconfirmed'; - is $update->user->email, $details->{username}, 'update email'; + is $update->user->email, $details->{username_register}, 'update email'; is $update->text, $details->{update}, 'update text'; is $add_alerts, $details->{add_alert} ? 1 : 0, 'do not sign up for alerts'; $mech->get_ok( $url ); $mech->content_contains("/report/$report_id#update_$update_id"); - my $unreg_user = FixMyStreet::DB->resultset( 'User' )->find( { email => $details->{username} } ); + my $unreg_user = FixMyStreet::DB->resultset( 'User' )->find( { email => $details->{username_register} } ); ok $unreg_user, 'found user'; @@ -497,6 +499,7 @@ for my $test ( desc => 'overriding email confirmation allows report confirmation with no email sent', initial_values => { name => '', + username_register => '', username => '', may_show_name => undef, add_alert => 1, @@ -510,7 +513,7 @@ for my $test ( }, form_values => { submit_update => 1, - username => 'unregistered@example.com', + username_register => 'unregistered@example.com', update => "update no email confirm", add_alert => 1, name => 'Unreg User', @@ -562,10 +565,10 @@ for my $test ( ok $update, 'found update in database'; is $update->state, 'confirmed', 'update confirmed'; - is $update->user->email, $details->{username}, 'update email'; + is $update->user->email, $details->{username_register}, 'update email'; is $update->text, $details->{update}, 'update text'; - my $unreg_user = FixMyStreet::DB->resultset( 'User' )->find( { email => $details->{username} } ); + my $unreg_user = FixMyStreet::DB->resultset( 'User' )->find( { email => $details->{username_register} } ); ok $unreg_user, 'found user'; @@ -1223,6 +1226,21 @@ $report->comments->delete; for my $test ( { + desc => 'submit an update with bad email and password', + form_values => { + submit_update => 1, + username => 'registered@', + update => 'Update from a user', + add_alert => undef, + password_sign_in => 'secret', + }, + field_errors => [ + 'Please enter a valid email', + "There was a problem with your login information. If you cannot remember your password, or do not have one, please fill in the \x{2018}No\x{2019} section of the form.", + 'Please enter your name', # FIXME Not really necessary error + ], + }, + { desc => 'submit an update for a registered user, signing in with wrong password', form_values => { submit_update => 1, @@ -1308,7 +1326,7 @@ subtest 'submit an update for a registered user, creating update by email' => su $mech->submit_form_ok( { with_fields => { submit_update => 1, - username => $user->email, + username_register => $user->email, update => 'Update from a user', add_alert => undef, name => 'New Name', @@ -1757,7 +1775,7 @@ for my $test ( fields => { submit_update => 1, name => 'Test User', - username => $report->user->email, + username_register => $report->user->email, may_show_name => 1, update => 'update from owner', add_alert => undef, @@ -1779,7 +1797,7 @@ for my $test ( submit_update => 1, name => 'Test User', may_show_name => 1, - username => $report->user->email, + username_register => $report->user->email, update => 'update from owner', add_alert => undef, fixed => 1, @@ -1844,7 +1862,7 @@ for my $test ( my $update = $report->comments->first; ok $update, 'found update'; is $update->text, $results->{update}, 'update text'; - is $update->user->email, $test->{fields}->{username}, 'update user'; + is $update->user->email, $test->{fields}->{username_register}, 'update user'; is $update->state, 'unconfirmed', 'update confirmed'; is $update->anonymous, $test->{anonymous}, 'user anonymous'; |