mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-26 04:21:52 -05:00
Merge pull request #2415 from alphagov/fix-branding-association
Fix automatic inheritance of org’s branding
This commit is contained in:
@@ -194,11 +194,11 @@ def dao_create_service(
|
||||
|
||||
service.organisation = organisation
|
||||
|
||||
if organisation.email_branding_id:
|
||||
service.email_branding = organisation.email_branding_id
|
||||
if organisation.email_branding:
|
||||
service.email_branding = organisation.email_branding
|
||||
|
||||
if organisation.letter_branding_id and not service.letter_branding:
|
||||
service.letter_branding = organisation.letter_branding_id
|
||||
if organisation.letter_branding and not service.letter_branding:
|
||||
service.letter_branding = organisation.letter_branding
|
||||
|
||||
db.session.add(service)
|
||||
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user