Don’t error if a user keeps same service name

Sometimes a user will hit the green button without actually changing
the service name (we saw this in a usability testing session).

Currently this gives an error saying ‘service name already in use’,
which is technically true (it’s in use by the current service) but
practically just annoying.

This commit adds some logic to silently ignore such requests.
This commit is contained in:
Chris Hill-Scott
2018-07-02 11:00:02 +01:00
parent aba9cf0ff3
commit d86291cb7a
2 changed files with 29 additions and 2 deletions

View File

@@ -291,6 +291,26 @@ def test_should_redirect_after_change_service_name(
assert mock_service_name_is_unique.called
def test_should_not_hit_api_if_service_name_hasnt_changed(
client_request,
mock_update_service,
mock_service_name_is_unique,
):
client_request.post(
'main.service_name_change',
service_id=SERVICE_ONE_ID,
_data={'name': 'service one'},
_expected_status=302,
_expected_redirect=url_for(
'main.service_settings',
service_id=SERVICE_ONE_ID,
_external=True,
),
)
assert not mock_service_name_is_unique.called
assert not mock_update_service.called
@pytest.mark.parametrize('user, expected_text, expected_link', [
(
active_user_with_permissions,