diff options
author | Struan Donald <struan@exo.org.uk> | 2018-11-01 15:19:53 +0000 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2018-11-19 13:29:49 +0000 |
commit | 3d7523690accf22af95704394832d8e675472a4b (patch) | |
tree | c5e70860c89cbaf362c81e27cb8cf04c67a413b3 /t | |
parent | b4618c61ff5ddf6db9662b06bc55a0f74b43c903 (diff) |
add report_prefill user permission
If set then when the user creates a new body report it will prefill the
report title and description with some basic text.
For mysociety/freshdesk#23
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/admin/users.t | 1 | ||||
-rw-r--r-- | t/app/controller/report_new.t | 25 |
2 files changed, 25 insertions, 1 deletions
diff --git a/t/app/controller/admin/users.t b/t/app/controller/admin/users.t index 08bfb73fd..be781d3ae 100644 --- a/t/app/controller/admin/users.t +++ b/t/app/controller/admin/users.t @@ -174,6 +174,7 @@ my %default_perms = ( "permissions[report_edit_priority]" => undef, "permissions[report_inspect]" => undef, "permissions[report_instruct]" => undef, + "permissions[report_prefill]" => undef, "permissions[contribute_as_another_user]" => undef, "permissions[contribute_as_anonymous_user]" => undef, "permissions[contribute_as_body]" => undef, diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t index c2e731e61..5f807f0e9 100644 --- a/t/app/controller/report_new.t +++ b/t/app/controller/report_new.t @@ -2048,10 +2048,33 @@ subtest "check map click ajax response for inspector" => sub { }, sub { $extra_details = $mech->get_ok_json( '/report/new/ajax?latitude=55.952055&longitude=-3.189579' ); }; - like $extra_details->{category}, qr/data-role="inspector/, 'category has correct data-role'; + like $extra_details->{category}, qr/data-prefill="0/, 'inspector prefill not set'; ok !$extra_details->{contribute_as}, 'no contribute as section'; }; +subtest "check map click ajax response for inspector and uk cobrand" => sub { + $mech->log_out_ok; + + my $extra_details; + $inspector->user_body_permissions->find_or_create({ + body => $bodies[4], + permission_type => 'planned_reports', + }); + $inspector->user_body_permissions->find_or_create({ + body => $bodies[4], + permission_type => 'report_inspect', + }); + + $mech->log_in_ok('inspector@example.org'); + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ { bromley => '.' } ], + MAPIT_URL => 'http://mapit.uk/', + }, sub { + $extra_details = $mech->get_ok_json( '/report/new/ajax?latitude=51.402096&longitude=0.015784' ); + }; + like $extra_details->{category}, qr/data-prefill="0/, 'inspector prefill not set'; +}; + for my $test ( { desc => 'map click ajax for contribute_as_another_user', |