Check for reply to email address before going live

We require that a user has a real reply-to email address before going
live. We can partially automate this by at least telling users who
haven’t done this.

This only applies for users that have email templates; we shouldn’t
bother users who aren’t going to send emails about this.
This commit is contained in:
Chris Hill-Scott
2018-02-27 14:25:20 +00:00
parent 7be08e2f74
commit d0ffff9e02
3 changed files with 47 additions and 8 deletions

View File

@@ -172,6 +172,12 @@ def request_to_go_live(service_id):
has_templates=(
service_api_client.count_service_templates(service_id) > 0
),
has_email_templates=(
service_api_client.count_service_templates(service_id, template_type='email') > 0
),
has_email_reply_to_address=bool(
service_api_client.get_reply_to_email_addresses(service_id)
)
)

View File

@@ -26,6 +26,14 @@
has_templates,
'Youve added some templates',
) }}
{% if has_email_templates %}
{{ tick_cross_done_not_done(
has_email_reply_to_address,
'Youve added an email reply to address on the <a href="{}">settings</a> page'.format(
url_for('main.service_settings', service_id=current_service.id)
)|safe,
) }}
{% endif %}
</ul>
<p>
You also need to:
@@ -34,10 +42,6 @@
<li>
read our <a href="{{ url_for('.terms') }}">terms of use</a>
</li>
<li>
specify your reply to email address or text message sender in your
<a href="{{ url_for('main.service_settings', service_id=current_service.id) }}">settings</a> page
</li>
<li>
make sure your messages follow the GOV.UK Service Manual standards for
<a href="https://www.gov.uk/service-manual/design/sending-emails-and-text-messages">writing text messages and emails</a>

View File

@@ -464,6 +464,12 @@ def test_should_raise_duplicate_name_handled(
(1, 'Done: Youve added some templates'),
(2, 'Done: Youve added some templates'),
])
@pytest.mark.parametrize('count_of_email_templates, reply_to_email_addresses, expected_reply_to_checklist_item', [
pytest.mark.xfail((0, [], ''), raises=IndexError),
pytest.mark.xfail((0, [{}], ''), raises=IndexError),
(1, [], 'Not done: Youve added an email reply to address on the settings page'),
(1, [{}], 'Done: Youve added an email reply to address on the settings page'),
])
def test_should_show_request_to_go_live_checklist(
client_request,
mocker,
@@ -471,14 +477,27 @@ def test_should_show_request_to_go_live_checklist(
expected_user_checklist_item,
count_of_templates,
expected_templates_checklist_item,
count_of_email_templates,
reply_to_email_addresses,
expected_reply_to_checklist_item,
):
def _count_templates(service_id, template_type=None):
return {
'email': count_of_email_templates
}.get(template_type, count_of_templates)
mock_count_users = mocker.patch(
'app.main.views.service_settings.user_api_client.get_count_of_users_with_permission',
return_value=count_of_users_with_manage_service
)
mock_count_templates = mocker.patch(
'app.main.views.service_settings.service_api_client.count_service_templates',
return_value=count_of_templates
side_effect=_count_templates
)
mock_get_reply_to_email_addresses = mocker.patch(
'app.main.views.service_settings.service_api_client.get_reply_to_email_addresses',
return_value=reply_to_email_addresses
)
page = client_request.get(
@@ -486,15 +505,25 @@ def test_should_show_request_to_go_live_checklist(
)
assert page.h1.text == 'Request to go live'
assert normalize_spaces(page.select('main ul li')[0].text) == expected_user_checklist_item
assert normalize_spaces(page.select('main ul li')[1].text) == expected_templates_checklist_item
checklist_items = page.select('main ul[class=bottom-gutter] li')
assert normalize_spaces(checklist_items[0].text) == expected_user_checklist_item
assert normalize_spaces(checklist_items[1].text) == expected_templates_checklist_item
assert normalize_spaces(checklist_items[2].text) == expected_reply_to_checklist_item
assert page.select_one('main .button')['href'] == url_for(
'main.submit_request_to_go_live',
service_id=SERVICE_ONE_ID,
)
mock_count_users.assert_called_once_with(SERVICE_ONE_ID, 'manage_settings')
mock_count_templates.assert_called_once_with(SERVICE_ONE_ID)
assert mock_count_templates.call_args_list == [
call(SERVICE_ONE_ID),
call(SERVICE_ONE_ID, template_type='email'),
]
if count_of_email_templates:
mock_get_reply_to_email_addresses.assert_called_once_with(SERVICE_ONE_ID)
def test_should_show_request_to_go_live(