aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/Cobrand/Peterborough.pm2
-rw-r--r--perllib/FixMyStreet/Roles/ConfirmValidation.pm6
-rw-r--r--t/Mock/MapIt.pm1
-rw-r--r--t/app/controller/report_new.t28
-rw-r--r--web/cobrands/fixmystreet-uk-councils/council_validation_rules.js5
5 files changed, 41 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Peterborough.pm b/perllib/FixMyStreet/Cobrand/Peterborough.pm
index fcdf44859..0de626c35 100644
--- a/perllib/FixMyStreet/Cobrand/Peterborough.pm
+++ b/perllib/FixMyStreet/Cobrand/Peterborough.pm
@@ -16,6 +16,8 @@ sub map_type { 'MasterMap' }
sub send_questionnaires { 0 }
+sub max_title_length { 50 }
+
sub disambiguate_location {
my $self = shift;
my $string = shift;
diff --git a/perllib/FixMyStreet/Roles/ConfirmValidation.pm b/perllib/FixMyStreet/Roles/ConfirmValidation.pm
index 6474c94d1..27592b33c 100644
--- a/perllib/FixMyStreet/Roles/ConfirmValidation.pm
+++ b/perllib/FixMyStreet/Roles/ConfirmValidation.pm
@@ -17,6 +17,8 @@ Confirm field lengths.
has max_report_length => ( is => 'ro', default => 2000 );
+has max_title_length => ( is => 'ro', default => 0 );
+
sub report_validation {
my ($self, $report, $errors) = @_;
@@ -28,6 +30,10 @@ sub report_validation {
$errors->{phone} = sprintf( _('Phone numbers are limited to %s characters in length.'), 20 );
}
+ if ( $self->max_title_length > 0 && length( $report->title ) > $self->max_title_length ) {
+ $errors->{title} = sprintf( _('Summaries are limited to %d characters in length. Please shorten your summary'), 50 );
+ }
+
if ( length( $report->detail ) > $self->max_report_length ) {
$errors->{detail} = sprintf( _('Reports are limited to %s characters in length. Please shorten your report'), $self->max_report_length );
}
diff --git a/t/Mock/MapIt.pm b/t/Mock/MapIt.pm
index c6e9b0af8..f7dd2eb83 100644
--- a/t/Mock/MapIt.pm
+++ b/t/Mock/MapIt.pm
@@ -51,6 +51,7 @@ my @PLACES = (
[ 'GU51 4AE', 51.279456, -0.846216, 2333, 'Hart District Council', 'DIS', 2227, 'Hampshire County Council', 'CTY' ],
[ 'WS1 4NH', 52.563074, -1.991032, 2535, 'Sandwell Borough Council', 'MTD' ],
[ 'PO30 5XJ', 50.71086, -1.29573, 2636, 'Isle of Wight Council', 'UTA' ],
+ [ 'PE1 1HF', 52.57146, -0.24201, 2566, 'Peterborough City Council', 'UTA' ],
[ 'OX28 4DS', 51.784721, -1.494453 ],
[ 'E14 2DN', 51.508536, '0.000001' ],
# Norway
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t
index 650defb70..e3126c7e1 100644
--- a/t/app/controller/report_new.t
+++ b/t/app/controller/report_new.t
@@ -59,6 +59,7 @@ for my $body (
{ area_id => 2600, name => 'Rutland County Council' },
{ area_id => 2234, name => 'Northamptonshire County Council' },
{ area_id => 2483, name => 'Hounslow Borough Council' },
+ { area_id => 2566, name => 'Peterborough City Council' },
) {
my $body_obj = $mech->create_body_ok($body->{area_id}, $body->{name});
push @bodies, $body_obj;
@@ -157,6 +158,11 @@ my $contact18 = $mech->create_contact_ok(
email => 'general-enquiry-2483@example.com',
non_public => 1,
);
+my $contact19 = $mech->create_contact_ok(
+ body_id => $body_ids{2566}, # Peterborough
+ category => 'Trees',
+ email => 'trees-2566@example.com',
+);
# test that the various bit of form get filled in and errors correctly
# generated.
@@ -681,6 +687,26 @@ foreach my $test (
changes => { },
errors => [ 'Summaries are limited to 120 characters in length. Please shorten your summary', 'Please enter some details'],
},
+ {
+ msg => 'Peterborough validation',
+ pc => 'PE1 1HF',
+ fields => {
+ title => 'This is a very long title that should fail the validation',
+ detail => '',
+ photo1 => '',
+ photo2 => '',
+ photo3 => '',
+ name => 'A User',
+ may_show_name => '1',
+ username => 'user@example.org',
+ phone => '',
+ category => 'Trees',
+ password_sign_in => '',
+ password_register => '',
+ },
+ changes => { },
+ errors => [ 'Summaries are limited to 50 characters in length. Please shorten your summary', 'Please enter some details'],
+ },
)
{
subtest "check form errors where $test->{msg}" => sub {
@@ -688,7 +714,7 @@ foreach my $test (
# submit initial pc form
FixMyStreet::override_config {
- ALLOWED_COBRANDS => [ { fixmystreet => '.' }, 'bromley', 'oxfordshire', 'rutland', 'lincolnshire', 'buckinghamshire', 'northamptonshire' ],
+ ALLOWED_COBRANDS => [ { fixmystreet => '.' }, 'bromley', 'oxfordshire', 'rutland', 'lincolnshire', 'buckinghamshire', 'northamptonshire', 'peterborough' ],
MAPIT_URL => 'http://mapit.uk/',
}, sub {
$mech->submit_form_ok( { with_fields => { pc => $test->{pc} } },
diff --git a/web/cobrands/fixmystreet-uk-councils/council_validation_rules.js b/web/cobrands/fixmystreet-uk-councils/council_validation_rules.js
index 3498c9a68..d8671084a 100644
--- a/web/cobrands/fixmystreet-uk-councils/council_validation_rules.js
+++ b/web/cobrands/fixmystreet-uk-councils/council_validation_rules.js
@@ -58,3 +58,8 @@ body_validation_rules = {
}
}
};
+
+body_validation_rules['Peterborough City Council'].title = {
+ required: true,
+ maxlength: 50
+};