Skip to content

Commit

Permalink
[Surrey] Add maximum detail length.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Dec 4, 2024
1 parent 136dd99 commit 7990f0f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
7 changes: 6 additions & 1 deletion perllib/FixMyStreet/Cobrand/Surrey.pm
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ sub reopening_disallowed { 1 }

sub allow_anonymous_reports { 'button' }

=item * Do not allow email addresses in title or detail
=item * Do not allow email addresses in title or detail, with detail maximum length
=back
Expand All @@ -149,6 +149,11 @@ sub report_validation {
$errors->{detail} = 'Please remove any email addresses and other personal information from your report';
}

my $max_report_length = 1000;
if ( length( $report->detail ) > $max_report_length ) {
$errors->{detail} = sprintf('Reports are limited to %s characters in length. Please shorten your report', $max_report_length );
}

return $errors;
}

Expand Down
2 changes: 1 addition & 1 deletion t/Mock/MapIt.pm
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ my @PLACES = (
[ '?', 51.558568, -0.207702, 2489, 'Barnet Borough Council', 'DIS' ],
[ '?', 51.418776, 0.005357, 2492, 'Lewisham Borough Council', 'DIS' ],
[ '?', 52.956196, -1.151204, 2412, 'Gedling Borough Council', 'DIS', 2236, 'Nottinghamshire County Council', 'CTY' ],
[ '?', 51.293415, -0.441269, 2242, 'Surrey County Council', 'DIS'],
[ 'KT11 1LZ', 51.293415, -0.441269, 2242, 'Surrey County Council', 'DIS'],
);

sub dispatch_request {
Expand Down
21 changes: 20 additions & 1 deletion t/app/controller/report_new_errors.t
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ for my $body (
{ area_id => 164186, name => 'Northamptonshire Highways', cobrand => 'northamptonshire' },
{ area_id => 2566, name => 'Peterborough City Council', cobrand => 'peterborough' },
{ area_id => 2508, name => 'Hackney Council', cobrand => 'hackney' },
{ area_id => 2242, name => 'Surrey Council', cobrand => 'surrey' },
) {
my $extra = { cobrand => $body->{cobrand} } if $body->{cobrand};
my $body_obj = $mech->create_body_ok($body->{area_id}, $body->{name}, $extra);
Expand Down Expand Up @@ -86,6 +87,11 @@ $mech->create_contact_ok(
category => 'Trees',
email => '[email protected]',
);
$mech->create_contact_ok(
body_id => $body_ids{2242}, # Surrey
category => 'Trees',
email => '[email protected]',
);
$mech->create_contact_ok(
body_id => $body_ids{2600}, # Rutland
category => 'Trees',
Expand Down Expand Up @@ -393,6 +399,19 @@ foreach my $test (
},
errors => [ 'Please make sure you are not including an email address', ],
},
{
msg => 'Surrey long detail',
pc => 'KT11 1LZ',
fields => {
%shared,
detail => 'X' . 'x' x 1001,
name => 'Bob Example',
username_register => '[email protected]',
category => 'Trees',
},
changes => { },
errors => [ 'Please enter a subject', 'Reports are limited to 1000 characters in length. Please shorten your report' ],
},
{
msg => 'Bromley long detail',
pc => 'BR1 3UH',
Expand Down Expand Up @@ -587,7 +606,7 @@ foreach my $test (

# submit initial pc form
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ { fixmystreet => '.' }, 'bromley', 'oxfordshire', 'rutland', 'lincolnshire', 'buckinghamshire', 'northamptonshire', 'peterborough', 'hackney' ],
ALLOWED_COBRANDS => [ { fixmystreet => '.' }, 'bromley', 'oxfordshire', 'rutland', 'lincolnshire', 'buckinghamshire', 'northamptonshire', 'peterborough', 'hackney', 'surrey' ],
MAPIT_URL => 'http://mapit.uk/',
}, sub {
$mech->submit_form_ok( { with_fields => { pc => $test->{pc} } },
Expand Down

0 comments on commit 7990f0f

Please sign in to comment.