From 0018ecd765fe13c2380e6a26cdf5b78470451e18 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 14 Jun 2018 15:04:01 +0100 Subject: [PATCH] =?UTF-8?q?Hide=20=E2=80=98Use=20my=20email=20address/phon?= =?UTF-8?q?e=20number=20link=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This link is useful for people who are setting up templates and want to test out how they look/how Notify works. ‘Caseworker’ users shouldn’t need to send themselves messages on a regular basis, so this link is another thing we can take away. --- app/main/views/send.py | 3 ++- tests/app/main/views/test_send.py | 31 +++++++++++++++++++++++-------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/app/main/views/send.py b/app/main/views/send.py index 89666923b..9158b2a0e 100644 --- a/app/main/views/send.py +++ b/app/main/views/send.py @@ -436,7 +436,8 @@ def send_test_step(service_id, template_id, step_index): request.endpoint == 'main.send_one_off_step' and step_index == 0 and template.template_type != 'letter' and - not (template.template_type == 'sms' and current_user.mobile_number is None) + not (template.template_type == 'sms' and current_user.mobile_number is None) and + current_user.has_permissions('view_activity') ): skip_link = ( 'Use my {}'.format(first_column_headings[template.template_type][0]), diff --git a/tests/app/main/views/test_send.py b/tests/app/main/views/test_send.py index 6ff4add68..93f2bb78b 100644 --- a/tests/app/main/views/test_send.py +++ b/tests/app/main/views/test_send.py @@ -1063,14 +1063,29 @@ def test_send_one_off_or_test_has_correct_page_titles( assert (len(page.select('.banner-tour')) == 1) == tour_shown -@pytest.mark.parametrize('user', ( - active_user_with_permissions, - active_caseworking_user, -)) -@pytest.mark.parametrize('template_mock, expected_link_text, expected_link_url', [ - (mock_get_service_template, 'Use my phone number', partial(url_for, 'main.send_test')), - (mock_get_service_email_template, 'Use my email address', partial(url_for, 'main.send_test')), - (mock_get_service_letter_template, None, None), +@pytest.mark.parametrize('user, template_mock, expected_link_text, expected_link_url', [ + ( + active_user_with_permissions, + mock_get_service_template, + 'Use my phone number', + partial(url_for, 'main.send_test') + ), + ( + active_user_with_permissions, + mock_get_service_email_template, + 'Use my email address', + partial(url_for, 'main.send_test') + ), + ( + active_user_with_permissions, + mock_get_service_letter_template, + None, None + ), + ( + active_caseworking_user, + mock_get_service_template, + None, None + ), ]) def test_send_one_off_has_skip_link( logged_in_client,