diff options
author | Marius Halden <marius.h@lden.org> | 2017-05-28 21:31:42 +0200 |
---|---|---|
committer | Marius Halden <marius.h@lden.org> | 2017-05-28 21:31:42 +0200 |
commit | 987124b09a32248414faf4d0d6615d43b29ac6f6 (patch) | |
tree | a549db8af723c981d3b346e855f25d6fd5ff8aa7 /t/app/controller/report_updates.t | |
parent | dbf56159e44c1560a413022451bf1a1c4cb22a52 (diff) | |
parent | a085b63ce09f87e83b75cda9b9cd08aadfe75d61 (diff) |
Merge tag 'v2.0.4' into fiksgatami-dev
Diffstat (limited to 't/app/controller/report_updates.t')
-rw-r--r-- | t/app/controller/report_updates.t | 51 |
1 files changed, 46 insertions, 5 deletions
diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t index 5a88097fa..de153978b 100644 --- a/t/app/controller/report_updates.t +++ b/t/app/controller/report_updates.t @@ -131,6 +131,19 @@ for my $test ( }; } +subtest "updates displayed on report with empty bodies_str" => sub { + my $old_bodies_str = $report->bodies_str; + $report->update({ bodies_str => undef }); + $comment->update({ problem_state => 'fixed' , mark_open => 'false', mark_fixed => 'false' }); + + $mech->get_ok("/report/$report_id"); + + my $meta = $mech->extract_update_metas; + is scalar @$meta, 1, 'update displayed'; + + $report->update({ bodies_str => $old_bodies_str }); +}; + subtest "unconfirmed updates not displayed" => sub { $comment->state( 'unconfirmed' ); $comment->update; @@ -594,7 +607,7 @@ for my $test ( name => $user->name, may_show_name => 1, update => 'Set state to unable to fix', - state => 'unable to fix', + state => 'no further action', }, state => 'unable to fix', }, @@ -653,6 +666,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 +687,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 +723,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'; @@ -1829,7 +1868,8 @@ for my $test ( subtest 'check have to be logged in for creator fixed questionnaire' => sub { $mech->log_out_ok(); - $mech->get_ok( "/questionnaire/submit?problem=$report_id&reported=Yes" ); + $mech->get( "/questionnaire/submit?problem=$report_id&reported=Yes" ); + is $mech->res->code, 400, "got 400"; $mech->content_contains( "I'm afraid we couldn't locate your problem in the database." ) }; @@ -1838,7 +1878,8 @@ subtest 'check cannot answer other user\'s creator fixed questionnaire' => sub { $mech->log_out_ok(); $mech->log_in_ok( $user2->email ); - $mech->get_ok( "/questionnaire/submit?problem=$report_id&reported=Yes" ); + $mech->get( "/questionnaire/submit?problem=$report_id&reported=Yes" ); + is $mech->res->code, 400, "got 400"; $mech->content_contains( "I'm afraid we couldn't locate your problem in the database." ) }; |