aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller
diff options
context:
space:
mode:
authorChris Mytton <chrism@mysociety.org>2020-03-09 20:20:35 +0000
committerChris Mytton <chrism@mysociety.org>2020-03-12 13:23:48 +0000
commita59ffd1675bef11c98607983608e1545c6f598bf (patch)
tree69d0478873d7c87127b0476f046bbf0e19013778 /t/app/controller
parent9b9313589f19e6ba6ce337964dcfae276b2ac9ca (diff)
Add Highways England junction lookup
This is taken from the sort-my-sign repo. It allows the user to search for motorways names and junction numbers, e.g. "M60, Junction 2", and then geocodes that using a SQLite database created from Highways England markerpost locations.
Diffstat (limited to 't/app/controller')
-rw-r--r--t/app/controller/around.t29
1 files changed, 29 insertions, 0 deletions
diff --git a/t/app/controller/around.t b/t/app/controller/around.t
index cd992270f..db7244863 100644
--- a/t/app/controller/around.t
+++ b/t/app/controller/around.t
@@ -400,4 +400,33 @@ subtest 'check nearby lookup' => sub {
$mech->content_contains('[51.754926,-1.256179,"yellow",' . $p->id . ',"Around page Test 1 for ' . $body->id . '","small",false]');
};
+my $he = Test::MockModule->new('HighwaysEngland');
+$he->mock('_lookup_db', sub {
+ my ($road, $table, $thing, $thing_name) = @_;
+
+ if ($road eq 'M6' && $thing eq '11') {
+ return { latitude => 52.65866, longitude => -2.06447 };
+ } elsif ($road eq 'M5' && $thing eq '132.5') {
+ return { latitude => 51.5457, longitude => 2.57136 };
+ }
+});
+
+subtest 'junction lookup' => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => 'fixmystreet',
+ MAPIT_URL => 'http://mapit.uk',
+ MAPIT_TYPES => ['EUR'],
+ }, sub {
+ $mech->log_out_ok;
+
+ $mech->get_ok('/');
+ $mech->submit_form_ok({ with_fields => { pc => 'M6, Junction 11' } });
+ $mech->content_contains('52.65866');
+
+ $mech->get_ok('/');
+ $mech->submit_form_ok({ with_fields => { pc => 'M5 132.5' } });
+ $mech->content_contains('51.5457');
+ };
+};
+
done_testing();