diff options
author | Matthew Somerville <matthew@mysociety.org> | 2015-01-22 15:57:45 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2015-02-13 11:44:07 +0000 |
commit | da63f72c27e16d491f9103b9a8cbdb2fd96d2b59 (patch) | |
tree | cfd6df35b4c41028943d8a1e669345b81be41913 /t/cobrand/fixamingata.t | |
parent | 04117b8be30b5d82d50cdc047ac4e7c19864f8ed (diff) |
Make sure all co-ordinates are stringified.
This includes MapIt postcode lookups, geocoding, query parameters, tile
clicks. Stringifying truncates them to six decimal places, which means
we no longer need any "short" versions anywhere, and the JSON response
will always uses a decimal point regardless of locale.
Diffstat (limited to 't/cobrand/fixamingata.t')
-rw-r--r-- | t/cobrand/fixamingata.t | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/t/cobrand/fixamingata.t b/t/cobrand/fixamingata.t index 105847576..714d475e1 100644 --- a/t/cobrand/fixamingata.t +++ b/t/cobrand/fixamingata.t @@ -1,12 +1,16 @@ use strict; use warnings; use Test::More; +use LWP::Protocol::PSGI; BEGIN { use FixMyStreet; FixMyStreet->test_mode(1); } +use t::MapIt; +use mySociety::Locale; + use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; @@ -96,6 +100,25 @@ like $email->header('Content-Type'), qr/iso-8859-1/, 'encoding looks okay'; like $email->body, qr/V=E4nligen,/, 'signature looks correct'; $mech->clear_emails_ok; +subtest "Test ajax decimal points" => sub { + # The following line is so we are definitely not in Swedish before + # requesting the page, so that the code performs a full switch to Swedish + mySociety::Locale::push('en-gb'); + + # A note to the future - the run_if_script line must be within a subtest + # otherwise it fails to work + LWP::Protocol::PSGI->register(t::MapIt->run_if_script, host => 'mapit.sweden'); + + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ 'fixamingata' ], + MAPIT_URL => 'http://mapit.sweden/' + }, sub { + $mech->get_ok('/ajax/lookup_location?term=12345'); + # We want an actual decimal point in a JSON response... + $mech->content_contains('51.5'); + }; +}; + END { $mech->delete_problems_for_body(1); ok $mech->host("www.fixmystreet.com"), "change host back"; |