diff --git a/app/service/rest.py b/app/service/rest.py index 6624c8979..db8c1aefa 100644 --- a/app/service/rest.py +++ b/app/service/rest.py @@ -119,7 +119,7 @@ def create_service(): def update_service(service_id): fetched_service = dao_fetch_service_by_id(service_id) # Capture the status change here as Marshmallow changes this later - service_going_live = fetched_service.restricted and not request.get_json().get('restricted') + service_going_live = fetched_service.restricted and not request.get_json().get('restricted', True) current_data = dict(service_schema.dump(fetched_service).data.items()) current_data.update(request.get_json()) diff --git a/tests/app/service/test_rest.py b/tests/app/service/test_rest.py index 8fb5e3fc7..1681444b7 100644 --- a/tests/app/service/test_rest.py +++ b/tests/app/service/test_rest.py @@ -1702,3 +1702,22 @@ def test_update_service_does_not_call_send_notification_for_live_service(sample_ assert resp.status_code == 200 assert not send_notification_mock.called + + +def test_update_service_does_not_call_send_notification_when_restricted_not_changed(sample_service, client, mocker): + send_notification_mock = mocker.patch('app.service.rest.send_notification_to_service_users') + + data = { + "name": 'Name of service' + } + + auth_header = create_authorization_header() + resp = client.post( + 'service/{}'.format(sample_service.id), + data=json.dumps(data), + headers=[auth_header], + content_type='application/json' + ) + + assert resp.status_code == 200 + assert not send_notification_mock.called