diff options
Diffstat (limited to 't/app/controller')
-rw-r--r-- | t/app/controller/around.t | 26 | ||||
-rw-r--r-- | t/app/controller/reports.t | 54 |
2 files changed, 76 insertions, 4 deletions
diff --git a/t/app/controller/around.t b/t/app/controller/around.t index 18281396a..cb36833ad 100644 --- a/t/app/controller/around.t +++ b/t/app/controller/around.t @@ -171,6 +171,19 @@ for my $permission ( qw/ report_inspect report_mark_private/ ) { }; $mech->content_contains( "Around page Test 3 for $body_edin_id", 'problem marked non public is visible' ); + $mech->content_contains( "Around page Test 2 for $body_edin_id", + 'problem marked public is visible' ); + + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ], + MAPIT_URL => 'http://mapit.uk/', + }, sub { + $mech->get_ok('/around?pc=EH1+1BB&status=non_public'); + }; + $mech->content_contains( "Around page Test 3 for $body_edin_id", + 'problem marked non public is visible' ); + $mech->content_lacks( "Around page Test 2 for $body_edin_id", + 'problem marked public is not visible' ); $user->user_body_permissions->delete(); $user->update({ from_body => $body2 }); @@ -189,6 +202,19 @@ for my $permission ( qw/ report_inspect report_mark_private/ ) { }; $mech->content_lacks( "Around page Test 3 for $body_edin_id", 'problem marked non public is not visible' ); + $mech->content_contains( "Around page Test 2 for $body_edin_id", + 'problem marked public is visible' ); + + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ], + MAPIT_URL => 'http://mapit.uk/', + }, sub { + $mech->get_ok('/around?pc=EH1+1BB&status=non_public'); + }; + $mech->content_lacks( "Around page Test 3 for $body_edin_id", + 'problem marked non public is not visible' ); + $mech->content_lacks( "Around page Test 2 for $body_edin_id", + 'problem marked public is visible' ); }; } diff --git a/t/app/controller/reports.t b/t/app/controller/reports.t index 3ba90c062..ac230ef95 100644 --- a/t/app/controller/reports.t +++ b/t/app/controller/reports.t @@ -220,8 +220,32 @@ for my $permission( qw/ report_inspect report_mark_private / ) { my $body = FixMyStreet::DB->resultset('Body')->find( $body_west_id ); my $body2 = FixMyStreet::DB->resultset('Body')->find( $body_edin_id ); my $user = $mech->log_in_ok( 'test@example.com' ); + + # from body, no permission $user->user_body_permissions->delete(); $user->update({ from_body => $body }); + + FixMyStreet::override_config { + MAPIT_URL => 'http://mapit.uk/', + }, sub { + $mech->get_ok('/reports/Westminster'); + }; + $problems = $mech->extract_problem_list; + is scalar @$problems, 4, 'only public problems are displayed if no permission'; + $mech->content_lacks('All reports Test 3 for ' . $body_west_id, 'non public problem is not visible if no permission'); + $mech->content_lacks('<option value="non_public">Private only</option>'); + + # from body, no permission, limited to private in url + FixMyStreet::override_config { + MAPIT_URL => 'http://mapit.uk/', + }, sub { + $mech->get_ok('/reports/Westminster?status=non_public'); + }; + $problems = $mech->extract_problem_list; + is scalar @$problems, 4, 'only public problems are displayed if no permission, despite override'; + $mech->content_lacks('All reports Test 3 for ' . $body_west_id, 'non public problem is not visible despite override'); + + # from body, has permission $user->user_body_permissions->find_or_create({ body => $body, permission_type => $permission, @@ -233,10 +257,22 @@ for my $permission( qw/ report_inspect report_mark_private / ) { $mech->get_ok('/reports/Westminster'); }; $problems = $mech->extract_problem_list; - is scalar @$problems, 5, 'only public problems are displayed'; + is scalar @$problems, 5, 'public and non-public problems are displayed if permission'; + $mech->content_contains('All reports Test 3 for ' . $body_west_id, 'non public problem is visible if permission'); + $mech->content_contains('<option value="non_public">Private only</option>'); - $mech->content_contains('All reports Test 3 for ' . $body_west_id, 'non public problem is visible'); + # From body, limited to private only + FixMyStreet::override_config { + MAPIT_URL => 'http://mapit.uk/', + }, sub { + $mech->get_ok('/reports/Westminster?status=non_public'); + }; + $problems = $mech->extract_problem_list; + is scalar @$problems, 1, 'only non-public problems are displayed with non_public filter'; + $mech->content_contains('All reports Test 3 for ' . $body_west_id, 'non public problem is visible with non_public filter'); + $mech->content_lacks('All reports Test 4 for ' . $body_west_id, 'public problem is not visible with non_public filter'); + # from other body, has permission $user->user_body_permissions->delete(); $user->update({ from_body => $body2 }); $user->user_body_permissions->find_or_create({ @@ -250,9 +286,19 @@ for my $permission( qw/ report_inspect report_mark_private / ) { $mech->get_ok('/reports/Westminster'); }; $problems = $mech->extract_problem_list; - is scalar @$problems, 4, 'only public problems are displayed'; + is scalar @$problems, 4, 'only public problems are displayed for other body user'; + $mech->content_contains('<option value="non_public">Private only</option>'); + $mech->content_lacks('All reports Test 3 for ' . $body_west_id, 'non public problem is not visible for other body user'); - $mech->content_lacks('All reports Test 3 for ' . $body_west_id, 'non public problem is not visible'); + # From other body, limited to private only + FixMyStreet::override_config { + MAPIT_URL => 'http://mapit.uk/', + }, sub { + $mech->get_ok('/reports/Westminster?status=non_public'); + }; + $problems = $mech->extract_problem_list; + is scalar @$problems, 4, 'non-public problems are not displayed for other body with override'; + $mech->content_lacks('All reports Test 3 for ' . $body_west_id, 'non public problem is not visible for other body with override'); }; } |