Redirect caseworking users off dashboard

They don’t have permission to see it; their home page is the list of
templates.
This commit is contained in:
Chris Hill-Scott
2018-06-14 11:39:06 +01:00
parent 84de1c5625
commit 7c849dccb7
2 changed files with 35 additions and 5 deletions

View File

@@ -23,6 +23,8 @@ from tests import (
)
from tests.conftest import (
SERVICE_ONE_ID,
active_caseworking_user,
active_user_view_permissions,
mock_get_inbound_sms_summary,
mock_get_inbound_sms_summary_with_no_messages,
normalize_spaces,
@@ -57,10 +59,17 @@ stub_template_stats = [
]
@pytest.mark.parametrize('user', (
active_user_view_permissions,
active_caseworking_user,
))
def test_redirect_from_old_dashboard(
logged_in_client
logged_in_client,
user,
mocker,
fake_uuid,
):
mocker.patch('app.user_api_client.get_user', return_value=user(fake_uuid))
expected_location = 'http://localhost/services/{}'.format(SERVICE_ONE_ID)
response = logged_in_client.get('/services/{}/dashboard'.format(SERVICE_ONE_ID))
@@ -70,6 +79,24 @@ def test_redirect_from_old_dashboard(
assert expected_location == url_for('main.service_dashboard', service_id=SERVICE_ONE_ID, _external=True)
def test_redirect_caseworkers_to_templates(
client_request,
mocker,
active_caseworking_user,
):
mocker.patch('app.user_api_client.get_user', return_value=active_caseworking_user)
client_request.get(
'main.service_dashboard',
service_id=SERVICE_ONE_ID,
_expected_status=302,
_expected_redirect=url_for(
'main.choose_template',
service_id=SERVICE_ONE_ID,
_external=True,
)
)
def test_get_started(
logged_in_client,
mocker,