aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpezholio <pezholio@gmail.com>2017-01-13 14:01:22 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2017-01-17 15:17:17 +0000
commitcd59528437a333523b8c3a06817da6da8ff315d3 (patch)
treea773b1c14677c59de1be83f64796ccab5c4b3b93
parentb2dc16e1d7dfe160e286496d498cbfe46a076dfe (diff)
Allow users with permission to see update username
-rw-r--r--perllib/FixMyStreet/DB/Result/Comment.pm6
-rw-r--r--t/app/controller/report_updates.t30
2 files changed, 33 insertions, 3 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm
index 75d9deb25..fb41bc7f0 100644
--- a/perllib/FixMyStreet/DB/Result/Comment.pm
+++ b/perllib/FixMyStreet/DB/Result/Comment.pm
@@ -246,7 +246,11 @@ sub meta_line {
if ($body eq 'Bromley Council') {
$body = "$body <img src='/cobrands/bromley/favicon.png' alt=''>";
}
- $meta = sprintf( _( 'Posted by %s (<strong>%s</strong>) at %s' ), $user_name, $body, Utils::prettify_dt( $self->confirmed ) );
+ if ($c->user_exists and $c->user->has_permission_to('view_body_contribute_details', $self->problem->bodies_str_ids)) {
+ $meta = sprintf( _( 'Posted by <strong>%s</strong> (%s) at %s' ), $body, $user_name, Utils::prettify_dt( $self->confirmed ) );
+ } else {
+ $meta = sprintf( _( 'Posted by <strong>%s</strong> at %s' ), $body, Utils::prettify_dt( $self->confirmed ) );
+ }
} else {
$meta = sprintf( _( 'Posted by %s at %s' ), FixMyStreet::Template::html_filter($self->name), Utils::prettify_dt( $self->confirmed ) )
}
diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t
index f7544f0a1..6fc7bb8e1 100644
--- a/t/app/controller/report_updates.t
+++ b/t/app/controller/report_updates.t
@@ -653,6 +653,18 @@ for my $test (
state => 'fixed - council',
report_bodies => $body->id . ',2505',
},
+ {
+ desc => 'from authority user show username for users with correct permissions',
+ fields => {
+ name => $user->name,
+ may_show_name => 1,
+ update => 'Set state to fixed',
+ state => 'fixed',
+ },
+ state => 'fixed - council',
+ report_bodies => $body->id . ',2505',
+ view_username => 1
+ },
) {
subtest $test->{desc} => sub {
$report->comments->delete;
@@ -662,6 +674,14 @@ for my $test (
}
$mech->log_in_ok( $user->email );
+
+ if ($test->{view_username}) {
+ ok $user->user_body_permissions->create({
+ body => $body,
+ permission_type => 'view_body_contribute_details'
+ }), 'Give user view_body_contribute_details permissions';
+ }
+
$user->from_body( $body->id );
$user->update;
@@ -690,8 +710,14 @@ for my $test (
} else {
like $update_meta->[0], qr/marked as $meta_state$/, 'update meta includes state change';
}
- like $update_meta->[0], qr{Test User \(Westminster City Council\)}, 'update meta includes council name';
- $mech->content_contains( 'Test User (<strong>Westminster City Council</strong>)', 'council name in bold');
+
+ if ($test->{view_username}) {
+ like $update_meta->[0], qr{Westminster City Council \(Test User\)}, 'update meta includes council and user name';
+ $user->user_body_permissions->delete_all;
+ } else {
+ like $update_meta->[0], qr{Westminster City Council}, 'update meta includes council name';
+ $mech->content_contains( '<strong>Westminster City Council</strong>', 'council name in bold');
+ }
$report->discard_changes;
is $report->state, $test->{state}, 'state set';