aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/Mock/MapIt.pm3
-rw-r--r--t/app/controller/report_new.t137
2 files changed, 139 insertions, 1 deletions
diff --git a/t/Mock/MapIt.pm b/t/Mock/MapIt.pm
index 0b9d398e8..f3f9f89b2 100644
--- a/t/Mock/MapIt.pm
+++ b/t/Mock/MapIt.pm
@@ -33,6 +33,9 @@ my @PLACES = (
[ '?', 51.754926, -1.256179, 2237, 'Oxfordshire County Council', 'CTY', 2421, 'Oxford City Council', 'DIS' ],
[ 'OX20 1SZ', 51.754926, -1.256179, 2237, 'Oxfordshire County Council', 'CTY', 2421, 'Oxford City Council', 'DIS' ],
[ 'OX16 9UP', 52.038712, -1.346397, 2237, 'Oxfordshire County Council', 'CTY', 2419, 'Cherwell District Council', 'DIS', 151767, "Banbury, Calthorpe & Easington", "DIW" ],
+ [ 'RG9 6TL', 51.561705, -0.868388, 2217, 'Buckinghamshire County Council', 'CTY'],
+ [ 'PE9 2GX', 52.656144, -0.502566, 2232, 'Lincolnshire County Council', 'CTY'],
+ [ 'LE15 0GJ', 52.670447, -0.727877, 2600, 'Rutland County Council', 'CTY'],
[ 'BR1 3UH', 51.4021, 0.01578, 2482, 'Bromley Council', 'LBO' ],
[ 'BR1 3UH', 51.402096, 0.015784, 2482, 'Bromley Council', 'LBO' ],
[ '?', 50.78301, -0.646929 ],
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t
index 5f807f0e9..133dc8047 100644
--- a/t/app/controller/report_new.t
+++ b/t/app/controller/report_new.t
@@ -42,6 +42,10 @@ for my $body (
{ area_id => 2333, name => 'Hart Council' },
{ area_id => 2535, name => 'Sandwell Borough Council' },
{ area_id => 1000, name => 'Highways England' },
+ { area_id => 2217, name => 'Buckinghamshire County Council' },
+ { area_id => 2232, name => 'Lincolnshire County Council' },
+ { area_id => 2237, name => 'Oxfordshire County Council' },
+ { area_id => 2600, name => 'Rutland County Council' },
) {
my $body_obj = $mech->create_body_ok($body->{area_id}, $body->{name});
push @bodies, $body_obj;
@@ -104,6 +108,26 @@ my $contact11 = $mech->create_contact_ok(
category => 'Pothole',
email => 'pothole-1000@example.com',
);
+my $contact12 = $mech->create_contact_ok(
+ body_id => $body_ids{2217}, # Buckinghamshire
+ category => 'Street lighting',
+ email => 'streetlights-2217@example.com',
+);
+my $contact13 = $mech->create_contact_ok(
+ body_id => $body_ids{2232}, # Lincolnshire
+ category => 'Trees',
+ email => 'trees-2232@example.com',
+);
+my $contact14 = $mech->create_contact_ok(
+ body_id => $body_ids{2237}, # Oxfordshire
+ category => 'Trees',
+ email => 'trees-2247@example.com',
+);
+my $contact15 = $mech->create_contact_ok(
+ body_id => $body_ids{2600}, # Rutland
+ category => 'Trees',
+ email => 'trees-2600@example.com',
+);
# test that the various bit of form get filled in and errors correctly
# generated.
@@ -495,6 +519,117 @@ foreach my $test (
},
errors => [ "Please enter a subject" ],
},
+ {
+ msg => 'Bromley long detail',
+ pc => 'BR1 3UH',
+ fields => {
+ fms_extra_title => 'MR',
+ title => '',
+ detail => 'X' . 'x' x 1751,
+ photo1 => '',
+ photo2 => '',
+ photo3 => '',
+ name => 'Bob Example',
+ may_show_name => '1',
+ username => 'bob@example.com',
+ email => 'bob@example.com',
+ phone => '',
+ category => 'Trees',
+ password_sign_in => '',
+ password_register => '',
+ remember_me => undef,
+ },
+ changes => { },
+ errors => [ 'Please enter a subject', 'Reports are limited to 1750 characters in length. Please shorten your report' ],
+ },
+ {
+ msg => 'Oxfordshire long detail',
+ pc => 'OX20 1SZ',
+ fields => {
+ title => '',
+ detail => 'X' . 'x' x 1701,
+ photo1 => '',
+ photo2 => '',
+ photo3 => '',
+ name => 'Bob Example',
+ may_show_name => '1',
+ username => 'bob@example.com',
+ email => 'bob@example.com',
+ phone => '',
+ category => 'Trees',
+ password_sign_in => '',
+ password_register => '',
+ remember_me => undef,
+ },
+ changes => { },
+ errors => [ 'Please enter a subject', 'Reports are limited to 1700 characters in length. Please shorten your report' ],
+ },
+ {
+ msg => 'Lincolnshire long phone',
+ pc => 'PE9 2GX',
+ fields => {
+ title => '',
+ detail => 'Detail',
+ photo1 => '',
+ photo2 => '',
+ photo3 => '',
+ name => 'Bob Example',
+ may_show_name => '1',
+ username => 'bob@example.com',
+ email => 'bob@example.com',
+ phone => '123456789 12345678910',
+ category => 'Trees',
+ password_sign_in => '',
+ password_register => '',
+ remember_me => undef,
+ },
+ changes => { },
+ errors => [ 'Please enter a subject', 'Phone numbers are limited to 20 characters in length.' ],
+ },
+ {
+ msg => 'Buckinghamshire long name',
+ pc => 'RG9 6TL',
+ fields => {
+ title => '',
+ detail => '',
+ photo1 => '',
+ photo2 => '',
+ photo3 => '',
+ name => 'This is a very long name that should fail validation',
+ may_show_name => '1',
+ username => 'bob@example.com',
+ email => 'bob@example.com',
+ phone => '',
+ category => 'Street lighting',
+ password_sign_in => '',
+ password_register => '',
+ remember_me => undef,
+ },
+ changes => { },
+ errors => [ 'Please enter a subject', 'Please enter some details', 'Names are limited to 50 characters in length.' ],
+ },
+ {
+ msg => 'Rutland long name',
+ pc => 'LE15 0GJ',
+ fields => {
+ title => '',
+ detail => '',
+ photo1 => '',
+ photo2 => '',
+ photo3 => '',
+ name => 'This is a very long name that should fail validation',
+ may_show_name => '1',
+ username => 'bob@example.com',
+ email => 'bob@example.com',
+ phone => '',
+ category => 'Trees',
+ password_sign_in => '',
+ password_register => '',
+ remember_me => undef,
+ },
+ changes => { },
+ errors => [ 'Please enter a subject', 'Please enter some details', 'Names are limited to 40 characters in length.' ],
+ },
)
{
subtest "check form errors where $test->{msg}" => sub {
@@ -502,7 +637,7 @@ foreach my $test (
# submit initial pc form
FixMyStreet::override_config {
- ALLOWED_COBRANDS => [ { fixmystreet => '.' } ],
+ ALLOWED_COBRANDS => [ { fixmystreet => '.' }, 'bromley', 'oxfordshire', 'rutland', 'lincolnshire', 'buckinghamshire' ],
MAPIT_URL => 'http://mapit.uk/',
}, sub {
$mech->submit_form_ok( { with_fields => { pc => $test->{pc} } },