aboutsummaryrefslogtreecommitdiffstats
path: root/t/cobrand/closest.t
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2017-12-22 12:53:48 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-05-09 12:57:56 +0100
commit22f0fed0b1ce6e7effac37e025bd55dc6043a838 (patch)
treea4bd66224c560418863319e9a6144d9b8702d462 /t/cobrand/closest.t
parent22815e994510659870987609d244b3f6324bab22 (diff)
ajax endpoint to return closest address.
/ajax/closest will return ajax with details of the closest address to the lat/lon passed in from the Bing geocoder. Tidy up find_closest() to use overloaded string rather than passing in whether you want a string or not.
Diffstat (limited to 't/cobrand/closest.t')
-rw-r--r--t/cobrand/closest.t16
1 files changed, 13 insertions, 3 deletions
diff --git a/t/cobrand/closest.t b/t/cobrand/closest.t
index 36fe78a01..6d28bb6f1 100644
--- a/t/cobrand/closest.t
+++ b/t/cobrand/closest.t
@@ -72,8 +72,18 @@ FixMyStreet::override_config {
$near = $c->find_closest_address_for_rss($report);
ok !$near, 'no closest address for RSS if not cached';
+
+ my $json = $mech->get_ok_json('/ajax/closest?lat=55&lon=-1');
+ is_deeply $json, {"road"=> "Constitution Hill","full_address"=>"Constitution Hill, London, SW1A"};
+};
+
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => 'fixmystreet',
+ MAPIT_URL => 'http://mapit.uk/',
+ BING_MAPS_API_KEY => 'test',
+}, sub {
+ my $json = $mech->get_ok_json('/ajax/closest?lat=55.952055&lon=-3.189579');
+ is_deeply $json, {"road"=> "Constitution Hill","full_address"=>"Constitution Hill, London, SW1A"};
};
-END {
- done_testing();
-}
+done_testing();