Repository navigation
Send an email when answers are saved - #2422
Conversation
f4d70f7 to
b64116b
Compare
5af0ce9 to
e3fe1cd
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Resume-link generation and mailer preview behavior contain unresolved correctness issues.
5 open findings
What changed in this PR
Adds email notifications to the save-progress flow, giving users a link to return to their form.
Changes:
- Stores saved-progress metadata and queues notification emails.
- Adds email templates, previews, and supporting tests.
- Shares locale selection, contact details, and email logging.
| File | Description |
|---|---|
| spec/services/save_form_progress_service_spec.rb | Tests metadata storage and email enqueueing. |
| spec/services/form_submission_service_spec.rb | Updates locale handling tests. |
| spec/services/api/v3/form_document_repository_spec.rb | Tests draft retrieval. |
| spec/requests/forms/save_progress_controller_spec.rb | Tests saved mode and email recipient. |
| spec/requests/forms/check_your_answers_controller_spec.rb | Updates email logging assertions. |
| spec/models/incomplete_submission_spec.rb | Tests saved form retrieval. |
| spec/models/current_job_logging_attributes_spec.rb | Tests generic email ID logging. |
| spec/mailers/submission_batch_mailer_preview.rb | Corrects preview class name. |
| spec/mailers/progress_saved_mailer_spec.rb | Tests email content and links. |
| spec/mailers/progress_saved_mailer_preview.rb | Adds saved-progress email previews. |
| spec/lib/flow/context_spec.rb | Tests submission locale selection. |
| spec/jobs/send_progress_saved_email_job_spec.rb | Tests delivery, logging, and failures. |
| spec/jobs/receive_confirmation_bounces_and_complaints_job_spec.rb | Updates email ID assertions. |
| db/schema.rb | Records saved-progress metadata columns. |
| db/migrate/20261015163042_add_submission_reference_to_incomplete_submissions.rb | Adds submission reference. |
| db/migrate/20261015162736_add_mode_to_incomplete_submissions.rb | Adds saved mode. |
| db/migrate/20261013160007_add_locale_to_incomplete_submissions.rb | Adds saved locale. |
| config/locales/en.yml | Adds notification text. |
| config/locales/cy.yml | Adds notification keys with English text. |
| app/views/submission_confirmation_mailer/_content.md.erb | Reuses shared contact details. |
| app/views/progress_saved_mailer/progress_saved_email.text.erb | Adds plain-text email rendering. |
| app/views/progress_saved_mailer/progress_saved_email.html.erb | Adds HTML email rendering. |
| app/views/progress_saved_mailer/_content.md.erb | Defines notification content. |
| app/views/mailer_shared/_support_contact_details.md.erb | Extracts shared contact details. |
| app/services/save_form_progress_service.rb | Saves metadata and queues email. |
| app/services/form_submission_service.rb | Uses context locale selection. |
| app/services/api/v3/form_document_repository.rb | Adds draft lookup. |
| app/resources/api/v3/form_document_resource.rb | Exposes draft retrieval. |
| app/models/incomplete_submission.rb | Resolves saved forms and modes. |
| app/models/current_job_logging_attributes.rb | Generalizes email ID logging. |
| app/mailers/progress_saved_mailer.rb | Builds saved-progress notifications. |
| app/lib/flow/context.rb | Centralizes locale selection. |
| app/jobs/send_progress_saved_email_job.rb | Delivers notifications asynchronously. |
| app/jobs/send_confirmation_email_job.rb | Uses generic email ID logging. |
| app/jobs/receive_confirmation_bounces_and_complaints_job.rb | Uses generic email ID logging. |
| app/jobs/application_job.rb | Adds saved-progress logging support. |
| app/controllers/forms/save_progress_controller.rb | Passes mode and recipient to saving service. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
e3fe1cd to
78f52fb
Compare
1aa1d5e to
f70fb00
Compare
We want to re-use this mailer content for the email we send when a user saves their answers.
We need to store the locale so we know whether to include Welsh in the email.
Store the mode so we can construct the correct link for the email to continue the saved progress for previews.
We want to use the same logic for getting the locale to store on IncompleteSubmissions.
Add method we can call directly when we want to get the draft form as opposed to a version of the live form.
We'll send this email when a user has saved their progress. For now, link to the form's URL but we'll updated this to link to a dedicated route for returning to complete a form later. This mailer uses the same SES configuration set as we use for confirmation emails. The configuration set defines how we handle bounces and complaints, which should be the same as for confirmation emails.
We now generate the submission reference when a user starts a new form submission, so we can save this alongside their answers so we can follow their session in the logs when they resume filling in their form.
Store the submission reference so we can include this in logs for sending the email to the user, and load it back into their session when they resume their submission.
We can use this logging attribute for other email types, so rename it to be more generic.
- Fix the base_url for forms_runner - Set the default mailer host to the same as we use in the production rails env, so we don't mistakenly think it will be set to the app's URL.
f70fb00 to
517f8ec
Compare
|
🎉 A review copy of this PR has been deployed! It is made of up two components It may take 5 minutes or so for the application to be fully deployed and working. If it still isn't ready For the sign in details and more information, see the review apps wiki page. |
chao-xian
left a comment
There was a problem hiding this comment.
All looks good! So nice to receive the email which then sends me back to the form I was in the middle of filling in


What problem does this pull request solve?
Trello card: https://trello.com/c/WRUjMeYT/
Things to consider when reviewing