aboutsummaryrefslogtreecommitdiffstats
path: root/t/geocode
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2018-01-24 18:01:56 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-02-12 16:17:25 +0000
commit7ec0d3f67766764967a8bb92099c582f8bd6aaf5 (patch)
tree2e9da126c8a3ea7994e43c1c693e5aa489b687c6 /t/geocode
parent27027ad882f5e1ddb8f2445e3b63972524ba82aa (diff)
Cobrands can pass `components` to Google Geocoder.
This allows more fine grained control over the geocoder search, e.g. to specify the administrative area or town. See the geocoder api docs: https://developers.google.com/maps/documentation/geocoding/intro#ComponentFiltering
Diffstat (limited to 't/geocode')
-rw-r--r--t/geocode/google.t22
1 files changed, 22 insertions, 0 deletions
diff --git a/t/geocode/google.t b/t/geocode/google.t
new file mode 100644
index 000000000..ee3c15ea8
--- /dev/null
+++ b/t/geocode/google.t
@@ -0,0 +1,22 @@
+package FixMyStreet::Cobrand::Tester;
+use parent 'FixMyStreet::Cobrand::Default';
+sub country { 'GB' }
+sub disambiguate_location { { components => 'country:IE' } }
+
+package main;
+
+use FixMyStreet::Test;
+use FixMyStreet::Geocode::Google;
+use Catalyst::Test 'FixMyStreet::App';
+use t::Mock::GoogleGeocoder;
+
+my $c = ctx_request('/');
+my $r = FixMyStreet::Geocode::Google::string("one result", $c);
+ok $r->{latitude};
+ok $r->{longitude};
+
+$c->stash->{cobrand} = FixMyStreet::Cobrand::Tester->new;
+$r = FixMyStreet::Geocode::Google::string("two results", $c);
+is scalar @{$r->{error}}, 2;
+
+done_testing;