aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Root.pm20
-rw-r--r--t/app/controller/index.t9
2 files changed, 25 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Root.pm b/perllib/FixMyStreet/App/Controller/Root.pm
index 461105b68..2dc770da5 100644
--- a/perllib/FixMyStreet/App/Controller/Root.pm
+++ b/perllib/FixMyStreet/App/Controller/Root.pm
@@ -33,11 +33,31 @@ sub auto : Private {
=head2 index
+Home page.
+
+If request includes certain parameters redirect to '/around' - this is to
+preserve old behaviour.
+
=cut
sub index : Path : Args(0) {
my ( $self, $c ) = @_;
+ my @old_param_keys = ( 'pc', 'x', 'y', 'lat', 'lon' );
+ my %old_params = ();
+
+ foreach my $key (@old_param_keys) {
+ my $val = $c->req->param($key);
+ next unless $val;
+ $old_params{$key} = $val;
+ }
+
+ if ( scalar keys %old_params ) {
+ my $around_uri = $c->uri_for( '/around', \%old_params );
+ $c->res->redirect($around_uri);
+ return;
+ }
+
}
=head2 default
diff --git a/t/app/controller/index.t b/t/app/controller/index.t
index 1d0bff33c..91f01c943 100644
--- a/t/app/controller/index.t
+++ b/t/app/controller/index.t
@@ -15,8 +15,9 @@ subtest "check that the form goes to /around" => sub {
$mech->submit_form_ok( { with_fields => { pc => 'SW1A 1AA', } } );
# check that we are at /around
- is $mech->res->uri->path, '/around', "Got to /around";
- is $mech->res->uri->query_form, { pc => 'SW1A 1AA' }, "query passed along";
+ is $mech->uri->path, '/around', "Got to /around";
+ is_deeply { $mech->uri->query_form }, { pc => 'SW1A 1AA' },
+ "query passed along";
};
subtest "check that requests with pc, x,y or lat,lon go to /around" => sub {
@@ -31,8 +32,8 @@ subtest "check that requests with pc, x,y or lat,lon go to /around" => sub {
$mech->get_ok($uri);
# check that we are at /around
- is $mech->res->uri->path, '/around', "Got to /around";
- is $mech->res->uri->query_form, $test, "query passed along";
+ is $mech->uri->path, '/around', "Got to /around";
+ is_deeply { $mech->uri->query_form }, $test, "query passed along";
}
};