aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2012-04-20 16:04:57 +0100
committerMatthew Somerville <matthew@mysociety.org>2012-07-13 09:42:50 +0100
commit02d06df3644d53aaa2611882491230fc28d843bd (patch)
treeb2d884368b242dae61cfcab98c3b920ab24a1011 /perllib/FixMyStreet/App/Controller
parentbd6ecb98fd3ad6f1602b0ea5593dea0bd96f8193 (diff)
Have a whole fake mapit (for #182) that works if MAPIT_URL is set accordingly.
Setting MAPIT_URL to .../fakemapit/ will then return one area, ID 161 and type ZZZ, whatever co-ordinate it is given. This means the default area type is now ZZZ, the UK specific types are moved into the UK cobrands, and the tests updated accordingly to still function (they assume UK-ness a lot, so probably need an ALLOWED_COBRANDS entry of "fixmystreet: 'localhost'" and for your host's domain to show fixmystreet too).
Diffstat (limited to 'perllib/FixMyStreet/App/Controller')
-rw-r--r--perllib/FixMyStreet/App/Controller/Council.pm1
-rwxr-xr-xperllib/FixMyStreet/App/Controller/FakeMapit.pm53
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm4
3 files changed, 57 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Council.pm b/perllib/FixMyStreet/App/Controller/Council.pm
index 48248e4fe..771603c22 100644
--- a/perllib/FixMyStreet/App/Controller/Council.pm
+++ b/perllib/FixMyStreet/App/Controller/Council.pm
@@ -37,6 +37,7 @@ there are no councils then return false.
sub load_and_check_councils : Private {
my ( $self, $c ) = @_;
+
my $latitude = $c->stash->{latitude};
my $longitude = $c->stash->{longitude};
diff --git a/perllib/FixMyStreet/App/Controller/FakeMapit.pm b/perllib/FixMyStreet/App/Controller/FakeMapit.pm
new file mode 100755
index 000000000..bc46df712
--- /dev/null
+++ b/perllib/FixMyStreet/App/Controller/FakeMapit.pm
@@ -0,0 +1,53 @@
+package FixMyStreet::App::Controller::FakeMapit;
+use Moose;
+use namespace::autoclean;
+
+BEGIN { extends 'Catalyst::Controller'; }
+
+=head1 NAME
+
+FixMyStreet::App::Controller::FakeMapit - Catalyst Controller
+
+=head1 DESCRIPTION
+
+A controller to fake mapit when we don't have it. If you set MAPIT_URL to
+.../fakemapit/ it should all just work, with a mapit that assumes the whole
+world is one area, with ID 161 and name "Default Area".
+
+=head1 METHODS
+
+=cut
+
+my $area = { "name" => "Default Area", "type" => "ZZZ", "id" => 161 };
+
+sub output : Private {
+ my ( $self, $c, $data ) = @_;
+ my $body = JSON->new->utf8(1)->encode( $data );
+ $c->res->content_type('application/json; charset=utf-8');
+ $c->res->body( $body );
+}
+
+sub point : Local {
+ my ( $self, $c ) = @_;
+ $c->detach( 'output', [ { 161 => $area } ] );
+}
+
+sub area : Local {
+ my ( $self, $c ) = @_;
+ $c->detach( 'output', [ $area ] );
+}
+
+sub areas : Local {
+ my ( $self, $c ) = @_;
+ $c->detach( 'output', [ { 161 => $area } ] );
+}
+
+sub children : Path('area/161/children') : Args(0) {
+ my ( $self, $c ) = @_;
+ $c->detach( 'output', [ {} ] );
+}
+
+__PACKAGE__->meta->make_immutable;
+
+1;
+
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index 9a7bb6192..3ef0410a9 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -43,6 +43,7 @@ sub index : Path : Args(0) {
$c->stash->{message} = _("Unable to look up areas in MaPit. Please try again later.") . ' ' .
sprintf(_('The error was: %s'), $@);
$c->stash->{template} = 'errors/generic.html';
+ return;
}
# For each area, add its link and perhaps alter its name if we need to for
@@ -70,6 +71,7 @@ sub index : Path : Args(0) {
$c->stash->{message} = _("There was a problem showing the All Reports page. Please try again later.") . ' ' .
sprintf(_('The error was: %s'), $@);
$c->stash->{template} = 'errors/generic.html';
+ return;
}
# Down here so that error pages aren't cached.
@@ -126,7 +128,7 @@ sub ward : Path : Args(2) {
# List of wards
unless ($c->stash->{ward}) {
- my $children = mySociety::MaPit::call('area/children', $c->stash->{council}->{id},
+ my $children = mySociety::MaPit::call('area/children', [ $c->stash->{council}->{id} ],
type => $mySociety::VotingArea::council_child_types,
);
foreach (values %$children) {