diff options
author | Dave Arter <davea@mysociety.org> | 2016-07-15 17:02:56 +0100 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2016-08-17 15:27:46 +0100 |
commit | f0220a9742ef0b7458b2dafaba5d9f860a741a91 (patch) | |
tree | 6d860ab0ad82864e94e9aa3215d6f1c3fa530ae6 /t/app | |
parent | 0ce7030998ff93c893d78a04669582423daceaad (diff) |
Require 'report_edit' permission for editing reports in admin
Diffstat (limited to 't/app')
-rw-r--r-- | t/app/controller/admin.t | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index 51307f756..aceaf2981 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -1331,6 +1331,53 @@ subtest "Users with from_body can't access fixmystreet.com admin" => sub { }; }; +$report->bodies_str(2237); +$report->cobrand('oxfordshire'); +$report->update; + +$mech->log_in_ok( $oxfordshireuser->email ); + +subtest "Users can't edit report without report_edit permission" => sub { + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ 'oxfordshire' ], + }, sub { + $mech->get("/admin/report_edit/$report_id"); + ok !$mech->res->is_success(), "want a bad response"; + is $mech->res->code, 404, "got 404, can't edit report without report_edit permission"; + }; +}; + +subtest "Users can edit report with report_edit permission" => sub { + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ 'oxfordshire' ], + }, sub { + $oxfordshireuser->user_body_permissions->create({ + body => $oxfordshire, + permission_type => 'report_edit', + }); + + $mech->get_ok("/admin/report_edit/$report_id"); + $mech->content_contains( $report->title ); + }; +}; + +subtest "Users can't edit another council's reports with their own council's report_edit permission" => sub { + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ 'oxfordshire' ], + }, sub { + $report->bodies_str(2482); + $report->cobrand('bromley'); + $report->update; + + $mech->get("/admin/report_edit/$report_id"); + ok !$mech->res->is_success(), "want a bad response"; + is $mech->res->code, 404, "got 404, can't edit report with incorrect body in report_edit permission"; + }; +}; + + +$mech->log_out_ok; +$oxfordshireuser->user_body_permissions->delete_all; $mech->delete_user( $user ); |