Fix automatic inheritance of org’s branding

When creating a service it should inherit it’s organisation’s branding,
if that organisation has branding.

This wasn’t working because we were referring to the ID of the branding
when making the association, not the branding itself.
This commit is contained in:
Chris Hill-Scott
2019-03-22 15:38:28 +00:00
parent 9866a38133
commit ef515400f3
2 changed files with 36 additions and 4 deletions

View File

@@ -49,6 +49,7 @@ from tests.app.db import (
create_letter_branding,
create_organisation,
create_domain,
create_email_branding,
)
from tests.app.db import create_user
@@ -306,6 +307,37 @@ def test_create_service_with_domain_sets_organisation(
assert json_resp['data']['organisation'] is None
def test_create_service_inherits_branding_from_organisation(
admin_request,
sample_user,
):
org = create_organisation()
email_branding = create_email_branding()
org.email_branding = email_branding
letter_branding = create_letter_branding()
org.letter_branding = letter_branding
create_domain('example.gov.uk', org.id)
sample_user.email_address = 'test@example.gov.uk'
json_resp = admin_request.post(
'service.create_service',
_data={
'name': 'created service',
'user_id': str(sample_user.id),
'message_limit': 1000,
'restricted': False,
'active': False,
'email_from': 'created.service',
'created_by': str(sample_user.id),
},
_expected_status=201
)
assert json_resp['data']['email_branding'] == str(email_branding.id)
assert json_resp['data']['letter_branding'] == str(letter_branding.id)
def test_create_service_with_domain_sets_letter_branding(admin_request, sample_user):
letter_branding = create_letter_branding(
name='test domain', filename='test-domain', domain='test.domain'