diff options
author | Struan Donald <struan@exo.org.uk> | 2017-12-22 12:53:48 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-05-09 12:57:56 +0100 |
commit | 22f0fed0b1ce6e7effac37e025bd55dc6043a838 (patch) | |
tree | a4bd66224c560418863319e9a6144d9b8702d462 /t | |
parent | 22815e994510659870987609d244b3f6324bab22 (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')
-rw-r--r-- | t/app/model/problem.t | 4 | ||||
-rw-r--r-- | t/cobrand/bromley.t | 1 | ||||
-rw-r--r-- | t/cobrand/closest.t | 16 | ||||
-rw-r--r-- | t/cobrand/oxfordshire.t | 1 | ||||
-rw-r--r-- | t/cobrand/rutland.t | 1 | ||||
-rw-r--r-- | t/sendreport/open311.t | 3 |
6 files changed, 22 insertions, 4 deletions
diff --git a/t/app/model/problem.t b/t/app/model/problem.t index 27f6aed66..b9bbe4682 100644 --- a/t/app/model/problem.t +++ b/t/app/model/problem.t @@ -514,6 +514,7 @@ foreach my $test ( { subtest $test->{ desc } => sub { my $override = { ALLOWED_COBRANDS => [ 'fixmystreet' ], + MAPIT_URL => 'http://mapit.uk/', BASE_URL => 'http://www.fixmystreet.com', }; if ( $test->{cobrand} && $test->{cobrand} =~ /hart/ ) { @@ -587,9 +588,10 @@ foreach my $test ( { }; } -subtest 'check can set mutiple emails as a single contact' => sub { +subtest 'check can set multiple emails as a single contact' => sub { my $override = { ALLOWED_COBRANDS => [ 'fixmystreet' ], + MAPIT_URL => 'http://mapit.uk/', }; my $contact = { diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t index a92786b18..e42ab5be2 100644 --- a/t/cobrand/bromley.t +++ b/t/cobrand/bromley.t @@ -83,6 +83,7 @@ for my $test ( FixMyStreet::override_config { STAGING_FLAGS => { send_reports => 1 }, ALLOWED_COBRANDS => [ 'fixmystreet', 'bromley' ], + MAPIT_URL => 'http://mapit.uk/', }, sub { $test_data = FixMyStreet::Script::Reports::send(); }; 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(); diff --git a/t/cobrand/oxfordshire.t b/t/cobrand/oxfordshire.t index f5abde27f..19a82742a 100644 --- a/t/cobrand/oxfordshire.t +++ b/t/cobrand/oxfordshire.t @@ -159,6 +159,7 @@ EOF subtest 'Reports are marked as inspected correctly' => sub { FixMyStreet::override_config { ALLOWED_COBRANDS => [ 'oxfordshire' ], + MAPIT_URL => 'http://mapit.uk/', }, sub { my $date = DateTime->new(year => 2017, month => 5, day => 5, hour => 12); diff --git a/t/cobrand/rutland.t b/t/cobrand/rutland.t index 8943e64fc..4d3c4befd 100644 --- a/t/cobrand/rutland.t +++ b/t/cobrand/rutland.t @@ -41,6 +41,7 @@ subtest 'testing special Open311 behaviour', sub { FixMyStreet::override_config { STAGING_FLAGS => { send_reports => 1 }, ALLOWED_COBRANDS => [ 'fixmystreet', 'rutland' ], + MAPIT_URL => 'http://mapit.uk/', }, sub { $test_data = FixMyStreet::Script::Reports::send(); }; diff --git a/t/sendreport/open311.t b/t/sendreport/open311.t index 23096aaac..26764dc19 100644 --- a/t/sendreport/open311.t +++ b/t/sendreport/open311.t @@ -37,6 +37,7 @@ subtest 'testing Open311 behaviour', sub { FixMyStreet::override_config { STAGING_FLAGS => { send_reports => 1 }, ALLOWED_COBRANDS => [ 'fixmystreet' ], + MAPIT_URL => 'http://mapit.uk/', }, sub { $test_data = FixMyStreet::Script::Reports::send(); }; @@ -72,6 +73,7 @@ subtest 'test report with multiple photos only sends one', sub { FixMyStreet::override_config { STAGING_FLAGS => { send_reports => 1 }, ALLOWED_COBRANDS => [ 'fixmystreet' ], + MAPIT_URL => 'http://mapit.uk/', }, sub { $test_data = FixMyStreet::Script::Reports::send(); }; @@ -104,6 +106,7 @@ subtest 'test sending multiple photos', sub { FixMyStreet::override_config { STAGING_FLAGS => { send_reports => 1 }, ALLOWED_COBRANDS => [ 'tester' ], + MAPIT_URL => 'http://mapit.uk/', }, sub { $test_data = FixMyStreet::Script::Reports::send(); }; |