When the organisation updates the crown attribute it should update all the services associated with that organisation too.

This commit is contained in:
Rebecca Law
2020-09-09 10:43:16 +01:00
parent a9168d38a7
commit 795a035fac
2 changed files with 17 additions and 0 deletions

View File

@@ -89,6 +89,9 @@ def dao_update_organisation(organisation_id, **kwargs):
if 'organisation_type' in kwargs: if 'organisation_type' in kwargs:
_update_organisation_services(organisation, 'organisation_type', only_where_none=False) _update_organisation_services(organisation, 'organisation_type', only_where_none=False)
if 'crown' in kwargs:
_update_organisation_services(organisation, 'crown', only_where_none=False)
if 'email_branding_id' in kwargs: if 'email_branding_id' in kwargs:
_update_organisation_services(organisation, 'email_branding') _update_organisation_services(organisation, 'email_branding')

View File

@@ -213,6 +213,20 @@ def test_update_organisation_does_not_override_service_branding(
assert sample_service.letter_branding == custom_letter_branding assert sample_service.letter_branding == custom_letter_branding
def test_update_organisation_updates_services_with_new_crown_type(
sample_service,
sample_organisation
):
sample_organisation.services.append(sample_service)
db.session.commit()
assert Service.query.get(sample_service.id).crown
dao_update_organisation(sample_organisation.id, crown=False)
assert not Service.query.get(sample_service.id).crown
def test_add_service_to_organisation(sample_service, sample_organisation): def test_add_service_to_organisation(sample_service, sample_organisation):
assert sample_organisation.services == [] assert sample_organisation.services == []