aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2011-09-12 10:38:20 +0100
committerMatthew Somerville <matthew@mysociety.org>2011-09-12 10:38:20 +0100
commit1e152d2b7e69e81193a3e8a46e36cb969ebef023 (patch)
tree2af2497ebec54e3e2e61e003bb3bd6af8fa73ce9
parent7af16dbb365a55df9493174f24d5aa80792f3440 (diff)
Fix redirect of old Open311 URIs when they have query parameters.
-rw-r--r--perllib/FixMyStreet/App/Controller/Open311.pm2
-rw-r--r--t/app/controller/open311.t13
2 files changed, 14 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Open311.pm b/perllib/FixMyStreet/App/Controller/Open311.pm
index 46d7801f6..fe1494b95 100644
--- a/perllib/FixMyStreet/App/Controller/Open311.pm
+++ b/perllib/FixMyStreet/App/Controller/Open311.pm
@@ -55,7 +55,7 @@ sub index : Path : Args(0) {
sub old_uri : Regex('^open311\.cgi') : Args(0) {
my ( $self, $c ) = @_;
( my $new = $c->req->path ) =~ s/open311.cgi/open311/;
- $c->res->redirect( "/$new", 301);
+ $c->res->redirect( $c->uri_for("/$new", $c->req->query_params), 301);
}
=head2 discovery
diff --git a/t/app/controller/open311.t b/t/app/controller/open311.t
new file mode 100644
index 000000000..9b0a6f8af
--- /dev/null
+++ b/t/app/controller/open311.t
@@ -0,0 +1,13 @@
+use strict;
+use warnings;
+
+use Test::More;
+
+use FixMyStreet::TestMech;
+my $mech = FixMyStreet::TestMech->new;
+
+# Check old .cgi links redirect correctly
+$mech->get_ok('/open311.cgi/v2/requests.rss?jurisdiction_id=fiksgatami.no&status=open&agency_responsible=1854');
+like $mech->uri, qr[/open311/v2/requests\.rss\?.{65}]; # Don't know order parameters will be in now
+
+done_testing();