diff options
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 8 | ||||
-rw-r--r-- | t/app/controller/report_new.t | 11 |
2 files changed, 15 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index ce2fe19f6..f8789fa3a 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -97,7 +97,7 @@ sub report_new : Path : Args(0) { # work out the location for this report and do some checks # Also show map if we're just updating the filters return $c->forward('redirect_to_around') - if !$c->forward('determine_location') || $c->get_param('filter_update'); + if !$c->forward('determine_location') || $c->get_param('pc_override') || $c->get_param('filter_update'); # create a problem from the submitted details $c->stash->{template} = "report/new/fill_in_details.html"; @@ -1558,6 +1558,12 @@ sub redirect_to_around : Private { $params->{$_} = $c->get_param($_); } + if (my $pc_override = $c->get_param('pc_override')) { + delete $params->{lat}; + delete $params->{lon}; + $params->{pc} = $pc_override; + } + my $csv = Text::CSV->new; foreach (qw(status filter_category)) { $csv->combine($c->get_param_list($_, 1)); diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t index b796578a0..8290faac0 100644 --- a/t/app/controller/report_new.t +++ b/t/app/controller/report_new.t @@ -24,10 +24,15 @@ subtest "test that bare requests to /report/new get redirected" => sub { MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->get_ok('/report/new?pc=SW1A%201AA'); + is $mech->uri->path, '/around', "went to /around"; + is_deeply { $mech->uri->query_form }, { pc => 'SW1A 1AA' }, + "pc correctly transferred"; + + $mech->get_ok('/report/new?pc_override=SW1A%201AA&latitude=51&longitude=-2'); + is $mech->uri->path, '/around', "went to /around"; + is_deeply { $mech->uri->query_form }, { pc => 'SW1A 1AA' }, + "pc correctly transferred, lat/lon gone"; }; - is $mech->uri->path, '/around', "went to /around"; - is_deeply { $mech->uri->query_form }, { pc => 'SW1A 1AA' }, - "pc correctly transferred"; }; my %body_ids; |