diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2015-02-13 12:25:34 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2015-02-13 12:25:34 +0000 |
commit | d2569bfe991ce1635131a1b1cf67cd55c3f258a4 (patch) | |
tree | 99a9e07df04f8f8b25becf61cd09625ac1750694 /t/MapIt.pm | |
parent | 0db002a977d00d0a6e11333e190de4746e009bfb (diff) | |
parent | da63f72c27e16d491f9103b9a8cbdb2fd96d2b59 (diff) |
Merge branch 'issues/fms-mobile/190'
Conflicts:
perllib/FixMyStreet/Geocode/Google.pm
Diffstat (limited to 't/MapIt.pm')
-rw-r--r-- | t/MapIt.pm | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/t/MapIt.pm b/t/MapIt.pm new file mode 100644 index 000000000..ebef934e1 --- /dev/null +++ b/t/MapIt.pm @@ -0,0 +1,36 @@ +package t::MapIt; + +use JSON; +use Web::Simple; + +use mySociety::Locale; + +has json => ( + is => 'lazy', + default => sub { + JSON->new->pretty->allow_blessed->convert_blessed; + }, +); + +sub dispatch_request { + my $self = shift; + + sub (GET + /postcode/*) { + my ($self, $postcode) = @_; + my $response = $self->postcode($postcode); + # We must make sure we output correctly for testing purposes, we might + # be within a different locale here... + my $json = mySociety::Locale::in_gb_locale { + $self->json->encode($response) }; + return [ 200, [ 'Content-Type' => 'application/json' ], [ $json ] ]; + }, +} + +sub postcode { + my ($self, $postcode) = @_; + return { + wgs84_lat => 51.5, wgs84_lon => 2.1, postcode => $postcode, + }; +} + +__PACKAGE__->run_if_script; |