mirror of
https://github.com/GSA/notifications-api.git
synced 2026-05-05 00:30:04 -04:00
Include the notification sender name when serializing notifications
The `serialize` method of the Notification model now includes the `created_by_name`. If a notification was sent as a one-off message this value will now be the name of the person who sent the notification. If a notification was sent through the API or by a CSV upload we don't record the id of the sender, so `created_by_name` will be `None`. This change affects the data that gets returned from these endpoints: * /v2/notifications/<notification_id> * /v2/notifications
This commit is contained in:
@@ -225,6 +225,17 @@ def test_letter_notification_serializes_with_address(client, sample_letter_notif
|
||||
assert res['postcode'] == 'SW1 1AA'
|
||||
|
||||
|
||||
def test_notification_serializes_created_by_name_with_no_created_by_id(client, sample_notification):
|
||||
res = sample_notification.serialize()
|
||||
assert res['created_by_name'] is None
|
||||
|
||||
|
||||
def test_notification_serializes_created_by_name_with_created_by_id(client, sample_notification, sample_user):
|
||||
sample_notification.created_by_id = sample_user.id
|
||||
res = sample_notification.serialize()
|
||||
assert res['created_by_name'] == sample_user.name
|
||||
|
||||
|
||||
def test_sms_notification_serializes_without_subject(client, sample_template):
|
||||
res = sample_template.serialize()
|
||||
assert res['subject'] is None
|
||||
|
||||
Reference in New Issue
Block a user