mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 02:11:11 -05:00
Don’t wipe domains when updating other attributes
The domains for an organisation should only be updated (or wiped) if a new list is explicitly passed in by the admin app.
This commit is contained in:
@@ -53,7 +53,7 @@ def dao_create_organisation(organisation):
|
|||||||
@transactional
|
@transactional
|
||||||
def dao_update_organisation(organisation_id, **kwargs):
|
def dao_update_organisation(organisation_id, **kwargs):
|
||||||
|
|
||||||
domains = kwargs.pop('domains', [])
|
domains = kwargs.pop('domains', None)
|
||||||
|
|
||||||
organisation = Organisation.query.filter_by(id=organisation_id).update(
|
organisation = Organisation.query.filter_by(id=organisation_id).update(
|
||||||
kwargs
|
kwargs
|
||||||
|
|||||||
@@ -201,6 +201,29 @@ def test_post_update_organisation_updates_domains(
|
|||||||
] == domain_list
|
] == domain_list
|
||||||
|
|
||||||
|
|
||||||
|
def test_update_other_organisation_attributes_doesnt_clear_domains(
|
||||||
|
admin_request,
|
||||||
|
notify_db_session,
|
||||||
|
):
|
||||||
|
org = create_organisation(name='test_org_2')
|
||||||
|
create_domain('example.gov.uk', org.id)
|
||||||
|
|
||||||
|
admin_request.post(
|
||||||
|
'organisation.update_organisation',
|
||||||
|
_data={
|
||||||
|
'agreement_signed': True,
|
||||||
|
},
|
||||||
|
organisation_id=org.id,
|
||||||
|
_expected_status=204
|
||||||
|
)
|
||||||
|
|
||||||
|
assert [
|
||||||
|
domain.domain for domain in org.domains
|
||||||
|
] == [
|
||||||
|
'example.gov.uk'
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def test_post_update_organisation_raises_400_on_existing_org_name(
|
def test_post_update_organisation_raises_400_on_existing_org_name(
|
||||||
admin_request, sample_organisation):
|
admin_request, sample_organisation):
|
||||||
org = create_organisation()
|
org = create_organisation()
|
||||||
|
|||||||
Reference in New Issue
Block a user