diff options
author | Dave Arter <davea@mysociety.org> | 2017-08-22 14:39:34 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2017-08-24 17:52:13 +0100 |
commit | 05c6a4b980b07a7c15b6b9727f6315d326e233a0 (patch) | |
tree | 99e00e3f5068bf401943e222bcabe7842a503710 /t | |
parent | 6f7efae58ef30ffbaddd42b4ac7f65380f6fe68a (diff) |
Redirect to original URL after inspecting
For mysociety/fixmystreetforcouncils#204
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/report_inspect.t | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t index 33486aa28..fcd7c724d 100644 --- a/t/app/controller/report_inspect.t +++ b/t/app/controller/report_inspect.t @@ -191,6 +191,42 @@ FixMyStreet::override_config { $report->update({ state => $old_state }); }; + subtest "post-inspect redirect is to the right place if URL set" => sub { + $user->user_body_permissions->create({ body => $oxon, permission_type => 'planned_reports' }); + $mech->get_ok("/report/$report_id"); + my $update_text = "This text was entered as an update by the user."; + $mech->submit_form_ok({ button => 'save', with_fields => { + public_update => $update_text, + include_update => "1", + post_inspect_url => "/" + }}); + is $mech->res->code, 200, "got 200"; + is $mech->res->previous->code, 302, "got 302 for redirect"; + is $mech->uri->path, '/', 'redirected to front page'; + $user->user_body_permissions->search({ body_id => $oxon->id, permission_type => 'planned_reports' })->delete; + }; + + subtest "post-inspect redirect is to the right place if URL not set" => sub { + $user->user_body_permissions->create({ body => $oxon, permission_type => 'planned_reports' }); + $user->set_extra_metadata(categories => [ $contact->id ]); + $user->update; + $mech->get_ok("/report/$report_id"); + my $update_text = "This text was entered as an update by the user."; + $mech->submit_form_ok({ button => 'save', with_fields => { + public_update => $update_text, + include_update => "1", + post_inspect_url => "" + }}); + is $mech->res->code, 200, "got 200"; + is $mech->res->previous->code, 302, "got 302 for redirect"; + is $mech->uri->path, '/around', 'redirected to /around'; + my %params = $mech->uri->query_form; + is $params{lat}, $report->latitude, "latitude param is correct"; + is $params{lon}, $report->longitude, "longitude param is correct"; + is $params{filter_category}, $contact->category, "categories param is correct"; + $user->user_body_permissions->search({ body_id => $oxon->id, permission_type => 'planned_reports' })->delete; + }; + foreach my $test ( { type => 'report_edit_priority', priority => 1 }, { type => 'report_edit_category', category => 1 }, |