mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-06 03:28:24 -04:00
Let users without send_messages view broadcasts
At the moment viewing a broadcast is limited to those users who have the `send_messages` permission. This doesn’t match how we describe the permissions on the team members page This commit makes it so that any team member can see a broadcast that’s in any state other than `draft`.
This commit is contained in:
@@ -639,6 +639,50 @@ def test_cant_approve_own_broadcast(
|
||||
)
|
||||
|
||||
|
||||
@freeze_time('2020-02-22T22:22:22.000000')
|
||||
def test_view_only_user_cant_approve_broadcast(
|
||||
mocker,
|
||||
client_request,
|
||||
service_one,
|
||||
active_user_with_permissions,
|
||||
active_user_view_permissions,
|
||||
mock_get_broadcast_template,
|
||||
fake_uuid,
|
||||
):
|
||||
mocker.patch(
|
||||
'app.broadcast_message_api_client.get_broadcast_message',
|
||||
return_value=broadcast_message_json(
|
||||
id_=fake_uuid,
|
||||
service_id=SERVICE_ONE_ID,
|
||||
template_id=fake_uuid,
|
||||
created_by_id=fake_uuid,
|
||||
finishes_at='2020-02-23T23:23:23.000000',
|
||||
status='pending-approval',
|
||||
),
|
||||
)
|
||||
mocker.patch('app.user_api_client.get_user', side_effect=[
|
||||
active_user_view_permissions, # Current user
|
||||
active_user_with_permissions, # User who created broadcast
|
||||
])
|
||||
service_one['permissions'] += ['broadcast']
|
||||
|
||||
page = client_request.get(
|
||||
'.view_broadcast_message',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
broadcast_message_id=fake_uuid,
|
||||
)
|
||||
|
||||
assert (
|
||||
normalize_spaces(page.select_one('.banner').text)
|
||||
) == (
|
||||
'This broadcast is waiting for approval '
|
||||
'You don’t have permission to approve broadcasts.'
|
||||
)
|
||||
|
||||
assert not page.select_one('form')
|
||||
assert not page.select_one('.banner a')
|
||||
|
||||
|
||||
@pytest.mark.parametrize('initial_status, expected_approval', (
|
||||
('draft', False,),
|
||||
('pending-approval', True),
|
||||
|
||||
Reference in New Issue
Block a user