diff options
author | Matthew Somerville <matthew@mysociety.org> | 2020-02-17 17:43:54 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2020-02-26 11:40:15 +0000 |
commit | 18adbe946c1104338e6abff159b4f9877154969c (patch) | |
tree | 5bae6c894981d3d90724f75c241c9d1e4c848dc2 /t | |
parent | 97133a07a181e6cccc207cc6598a08e8028ad7ca (diff) |
Add a new "staff" contact state.
This state will appear when reporting if you are logged in as a staff
member of the relevant body, but otherwise not appear on the site.
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/report_new_staff.t | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/t/app/controller/report_new_staff.t b/t/app/controller/report_new_staff.t index 5d4d05e52..ee9dff9e4 100644 --- a/t/app/controller/report_new_staff.t +++ b/t/app/controller/report_new_staff.t @@ -18,7 +18,7 @@ for my $body ( # Let's make some contacts to send things to! $mech->create_contact_ok( body_id => $body_ids{2651}, category => 'Street lighting', email => 'highways@example.com' ); -$mech->create_contact_ok( body_id => $body_ids{2651}, category => 'Trees', email => 'trees@example.com' ); +my $edin_trees = $mech->create_contact_ok( body_id => $body_ids{2651}, category => 'Trees', email => 'trees@example.com' ); $mech->create_contact_ok( body_id => $body_ids{2482}, category => 'Trees', email => 'trees@example.com' ); $mech->create_contact_ok( body_id => $body_ids{2237}, category => 'Trees', email => 'trees-2247@example.com' ); @@ -224,4 +224,34 @@ for my $test ( }; } +subtest 'staff-only categories when reporting' => sub { + FixMyStreet::override_config { + MAPIT_URL => 'http://mapit.uk/', + MAPIT_TYPES => ['UTA'], + }, sub { + $inspector->update({ is_superuser => 1 }); + $mech->log_in_ok('inspector@example.org'); + + $mech->get_ok('/admin/body/' . $body_ids{2651} . '/Trees'); + $mech->submit_form_ok({ with_fields => { state => 'staff' } }, 'mark Trees as staff-only'); + $edin_trees->discard_changes; + is $edin_trees->state, 'staff', 'category is staff only'; + + my $extra_details = $mech->get_ok_json( '/report/new/ajax?latitude=55.952055&longitude=-3.189579' ); + is_deeply [ sort keys %{$extra_details->{by_category}} ], [ 'Street lighting', 'Trees' ], 'Superuser can see staff-only category'; + + $inspector->update({ is_superuser => 0 }); + $extra_details = $mech->get_ok_json( '/report/new/ajax?latitude=55.952055&longitude=-3.189579' ); + is_deeply [ sort keys %{$extra_details->{by_category}} ], [ 'Street lighting', 'Trees' ], 'Body staff user can see staff-only category'; + + $inspector->update({ from_body => $body_ids{2482} }); + $extra_details = $mech->get_ok_json( '/report/new/ajax?latitude=55.952055&longitude=-3.189579' ); + is_deeply [ sort keys %{$extra_details->{by_category}} ], [ 'Street lighting' ], 'Different body staff user cannot see staff-only category'; + + $mech->log_out_ok; + $extra_details = $mech->get_ok_json( '/report/new/ajax?latitude=55.952055&longitude=-3.189579' ); + is_deeply [ sort keys %{$extra_details->{by_category}} ], [ 'Street lighting' ], 'Normal user cannot see staff-only category'; + }; +}; + done_testing; |