aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2020-03-27 10:59:15 +0000
committerStruan Donald <struan@exo.org.uk>2020-03-31 09:58:58 +0100
commit6e07f9477d0218151f80a181c7832fe73c6accac (patch)
tree3237052afd757cc01801b765fb4c40919e62c47a
parent2187335bcd3fff4e0199e25d381d9f9d865e85c9 (diff)
[Highways England] Error if road name searched.
-rw-r--r--perllib/FixMyStreet/Cobrand/HighwaysEngland.pm12
-rw-r--r--t/cobrand/highwaysengland.t17
2 files changed, 29 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/HighwaysEngland.pm b/perllib/FixMyStreet/Cobrand/HighwaysEngland.pm
index ee4754827..87cf073eb 100644
--- a/perllib/FixMyStreet/Cobrand/HighwaysEngland.pm
+++ b/perllib/FixMyStreet/Cobrand/HighwaysEngland.pm
@@ -43,6 +43,18 @@ sub example_places {
return $self->feature('example_places') || $self->next::method();
}
+sub geocode_postcode {
+ my ( $self, $s ) = @_;
+
+ if ($s =~ /^\s*[AM]\d+\s*$/i) {
+ return {
+ error => "Please be more specific about the location of the issue, eg M1, Jct 16 or A5, Towcester"
+ };
+ }
+
+ return $self->next::method($s);
+}
+
sub allow_photo_upload { 0 }
sub allow_anonymous_reports { 'button' }
diff --git a/t/cobrand/highwaysengland.t b/t/cobrand/highwaysengland.t
new file mode 100644
index 000000000..3c7632563
--- /dev/null
+++ b/t/cobrand/highwaysengland.t
@@ -0,0 +1,17 @@
+use FixMyStreet::TestMech;
+use FixMyStreet::App;
+
+# disable info logs for this test run
+FixMyStreet::App->log->disable('info');
+END { FixMyStreet::App->log->enable('info'); }
+
+
+my $he = FixMyStreet::Cobrand::HighwaysEngland->new();
+
+my $r = $he->geocode_postcode('M1');
+ok $r->{error}, "searching for road only generates error";
+
+$r = $he->geocode_postcode('m1');
+ok $r->{error}, "searching for lowecase road only generates error";
+
+done_testing();