aboutsummaryrefslogtreecommitdiffstats
path: root/t/app
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2018-11-01 10:50:38 +0000
committerStruan Donald <struan@exo.org.uk>2018-11-19 13:29:49 +0000
commitb4618c61ff5ddf6db9662b06bc55a0f74b43c903 (patch)
tree17e4c2a7651a60b14bd37a2bc2d19f670ddc4153 /t/app
parentb35552138fd66673df46747549989d545bbcfa9f (diff)
add default_to_body permission
If a user has this permission then the report_as dropdown will default to reporting as the body. For mysociety/freshdesk#23
Diffstat (limited to 't/app')
-rw-r--r--t/app/controller/admin/users.t1
-rw-r--r--t/app/controller/report_as_other.t18
2 files changed, 19 insertions, 0 deletions
diff --git a/t/app/controller/admin/users.t b/t/app/controller/admin/users.t
index 903ec3104..08bfb73fd 100644
--- a/t/app/controller/admin/users.t
+++ b/t/app/controller/admin/users.t
@@ -177,6 +177,7 @@ my %default_perms = (
"permissions[contribute_as_another_user]" => undef,
"permissions[contribute_as_anonymous_user]" => undef,
"permissions[contribute_as_body]" => undef,
+ "permissions[default_to_body]" => undef,
"permissions[view_body_contribute_details]" => undef,
"permissions[user_edit]" => undef,
"permissions[user_manage_permissions]" => undef,
diff --git a/t/app/controller/report_as_other.t b/t/app/controller/report_as_other.t
index 367d9a1d4..f256374a8 100644
--- a/t/app/controller/report_as_other.t
+++ b/t/app/controller/report_as_other.t
@@ -282,6 +282,24 @@ subtest "Body user, has permission to add update as anonymous user" => sub {
is $update->anonymous, 1, 'update anonymous';
};
+for my $test_permission ( qw/planned_reports default_to_body/ ) {
+ subtest "$test_permission user defaults to reporting as body" => sub {
+ $_->delete for $user->user_body_permissions;
+ for my $permission ( 'contribute_as_another_user', 'contribute_as_anonymous_user', 'contribute_as_body', $test_permission ) {
+ $user->user_body_permissions->create({ body => $body, permission_type => $permission })
+ }
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'fixmystreet' ],
+ MAPIT_URL => 'http://mapit.uk/',
+ PHONE_COUNTRY => 'GB',
+ }, sub {
+ $mech->get_ok('/report/new?latitude=51.7549262252&longitude=-1.25617899435');
+ };
+
+ is $mech->visible_form_values()->{form_as}, 'body', 'report as body is default';
+ };
+}
+
done_testing();
sub start_report {