aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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();