diff options
author | pezholio <pezholio@gmail.com> | 2017-01-11 14:17:34 +0000 |
---|---|---|
committer | pezholio <pezholio@gmail.com> | 2017-01-17 14:33:19 +0000 |
commit | e81d5b686a44e7a07db276cccc718c4e28a28a1c (patch) | |
tree | 1d02a25d57ad72f784671be5a6a625055ef415cf /t/app/controller/report_display.t | |
parent | f53446b021827a298583d589e15bdb87a1b00328 (diff) |
Show user details for users with correct permissions
Diffstat (limited to 't/app/controller/report_display.t')
-rw-r--r-- | t/app/controller/report_display.t | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/t/app/controller/report_display.t b/t/app/controller/report_display.t index fad8b2bbb..b35a4a026 100644 --- a/t/app/controller/report_display.t +++ b/t/app/controller/report_display.t @@ -210,13 +210,13 @@ foreach my $meta ( $report->update; subtest "test correct problem meta information" => sub { $mech->get_ok("/report/$report_id"); - + is $mech->extract_problem_meta, $meta->{meta}; }; } -for my $test ( +for my $test ( { description => 'new report', date => DateTime->now, @@ -385,7 +385,7 @@ for my $test ( my $body_westminster = $mech->create_body_ok(2504, 'Westminster City Council'); my $body_camden = $mech->create_body_ok(2505, 'Camden Borough Council'); -for my $test ( +for my $test ( { desc => 'no state dropdown if user not from authority', from_body => undef, @@ -530,6 +530,57 @@ subtest "Zurich banners are displayed correctly" => sub { }; }; +my $oxfordshire = $mech->create_body_ok(2237, 'Oxfordshire County Council', id => 2237); +my $oxfordshireuser = $mech->create_user_ok('counciluser@example.com', name => 'Council User', from_body => $oxfordshire); + +subtest "check user details show when a user has correct permissions" => sub { + $report->update( { + name => 'Oxfordshire County Council', + user_id => $oxfordshireuser->id, + service => '', + anonymous => 'f', + bodies_str => $oxfordshire->id, + confirmed => '2012-01-10 15:17:00' + }); + + ok $oxfordshireuser->user_body_permissions->create({ + body => $oxfordshire, + permission_type => 'view_body_contribute_details', + }); + + $mech->log_in_ok( $oxfordshireuser->email ); + ok $mech->get("/report/$report_id"), "get '/report/$report_id'"; + is $mech->extract_problem_meta, + 'Reported in the Roads category by Oxfordshire County Council (Council User) at 15:17, Tue 10 January 2012', + 'correct problem meta information'; + + ok $oxfordshireuser->user_body_permissions->delete_all, "Remove view_body_contribute_details permissions"; + + ok $mech->get("/report/$report_id"), "get '/report/$report_id'"; + is $mech->extract_problem_meta, + 'Reported in the Roads category by Oxfordshire County Council at 15:17, Tue 10 January 2012', + 'correct problem meta information for user without relevant permissions'; + + $mech->log_out_ok; + + ok $mech->get("/report/$report_id"), "get '/report/$report_id'"; + is $mech->extract_problem_meta, + 'Reported in the Roads category by Oxfordshire County Council at 15:17, Tue 10 January 2012', + 'correct problem meta information for logged out user'; + +}; + +subtest "check brackets don't appear when username and report name are the same" => sub { + $report->update( { + name => 'Council User' + }); + + $mech->log_in_ok( $oxfordshireuser->email ); + ok $mech->get("/report/$report_id"), "get '/report/$report_id'"; + is $mech->extract_problem_meta, + 'Reported in the Roads category by Council User at 15:17, Tue 10 January 2012', + 'correct problem meta information'; +}; END { $mech->delete_user('test@example.com'); |