Bug fix: update normalised_to, not just to after letter sanitise

When a precompiled letter is sent to us, we set the `to` field as
'Provided as PDF' in
1c1023a877/app/v2/notifications/post_notifications.py (L100-L104)

This then also sets `normalised_to` as `providedaspdf`.

However, when template preview sanitises the letter, pulls out the
address and gives it to the API, we were only setting `to` to be
the new address and had forgotten to also amend `normalised_to` to
be the normalised version. This meant that for all these letters
we accidentally left `normalised_to` as `providedaspdf`. The impact
of this was that we can not then search for these letters in the
admin user interface as they rely on the `normalised_to` field
containing the recipient address.

This commit fixes that bug by also setting the `normalised_to`
field
This commit is contained in:
David McDonald
2021-10-27 10:54:21 +01:00
parent 2edbdec4ee
commit 5a51ab6131
2 changed files with 2 additions and 0 deletions

View File

@@ -843,6 +843,7 @@ def test_process_sanitised_letter_with_valid_letter(
assert sample_letter_notification.status == expected_status
assert sample_letter_notification.billable_units == 1
assert sample_letter_notification.to == 'A. User\nThe house on the corner'
assert sample_letter_notification.normalised_to == 'a.userthehouseonthecorner'
assert not [x for x in scan_bucket.objects.all()]
assert not [x for x in template_preview_bucket.objects.all()]