Skip to content

Commit

Permalink
Merge pull request #1983 from DFE-Digital/consent-emails
Browse files Browse the repository at this point in the history
Add consent emails
  • Loading branch information
thomasleese authored Feb 13, 2024
2 parents 3b38382 + b14031a commit 2d7a605
Show file tree
Hide file tree
Showing 6 changed files with 221 additions and 0 deletions.
30 changes: 30 additions & 0 deletions app/mailers/teacher_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,36 @@ def application_received
)
end

def consent_reminder
@expires_at =
assessment.qualification_requests.consent_required.map(&:expires_at).max

view_mail(
GOVUK_NOTIFY_TEMPLATE_ID,
to: teacher.email,
subject: I18n.t("mailer.teacher.consent_reminder.subject"),
)
end

def consent_requested
@expires_at =
assessment.qualification_requests.consent_required.map(&:expires_at).max

view_mail(
GOVUK_NOTIFY_TEMPLATE_ID,
to: teacher.email,
subject: I18n.t("mailer.teacher.consent_requested.subject"),
)
end

def consent_submitted
view_mail(
GOVUK_NOTIFY_TEMPLATE_ID,
to: teacher.email,
subject: I18n.t("mailer.teacher.consent_submitted.subject"),
)
end

def further_information_received
view_mail(
GOVUK_NOTIFY_TEMPLATE_ID,
Expand Down
24 changes: 24 additions & 0 deletions app/views/teacher_mailer/consent_reminder.text.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Dear <%= application_form_full_name(@application_form) %>,

We recently wrote to you asking for your consent to verify some of your qualifications as part of your QTS application.

We have not received your consent documents. If you do not send them by <%= @expires_at.to_fs(:date) %> we will not be able to proceed with your application.

## What you need to do

Download each document then:

- print it
- sign it, making sure your signature is clear
- scan or photograph it
- upload the signed document

[Sign in to access your documents](<%= new_teacher_session_url %>)

You need to sign and upload these documents by <%= @expires_at.to_fs(:date) %> so that we can proceed with your application.

## Why we need your written consent

We need your written consent so we can share your data with organisations that can verify your qualifications. This is in accordance with UK General Data Protection Regulation (GDPR).

<%= render "shared/teacher_mailer/footer" %>
24 changes: 24 additions & 0 deletions app/views/teacher_mailer/consent_requested.text.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Dear <%= application_form_full_name(@application_form) %>,

As part of your QTS application we need to verify some of your qualifications. To allow us to do this you need to sign and return a consent document for each qualification we need to verify.

Consent documents have been added to your application.

## What you need to do

Download each document then:

- print it
- sign it, making sure your signature is clear
- scan or photograph it
- upload the signed document

[Sign in to access your documents](<%= new_teacher_session_url %>)

You need to sign and upload these documents by <%= @expires_at.to_fs(:date) %> so that we can proceed with your application.

## Why we need your written consent

We need your written consent so we can share your data with organisations that can verify your qualifications. This is in accordance with UK General Data Protection Regulation (GDPR).

<%= render "shared/teacher_mailer/footer" %>
15 changes: 15 additions & 0 deletions app/views/teacher_mailer/consent_submitted.text.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Dear <%= application_form_full_name(@application_form) %>,

Thank you for submitting the consent documents required to progress your QTS application.

<%= render "shared/teacher_mailer/reference_number" %>

## What happens next?

Once an assessor has checked the documents to make sure you’ve provided the required information, they’ll continue reviewing your application.

If no further information is needed, we’ll contact you with a final QTS application decision once all checks and verifications have been completed.

<%= render "shared/teacher_mailer/any_questions_contact" %>

<%= render "shared/teacher_mailer/footer" %>
6 changes: 6 additions & 0 deletions config/locales/mailer.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ en:
1: Your draft QTS application will be deleted in 1 week
application_received:
subject: We’ve received your application for qualified teacher status (QTS)
consent_reminder:
subject: "Reminder: we need your written consent to progress your QTS application"
consent_requested:
subject: We need your written consent to progress your QTS application
consent_submitted:
subject: We’ve received your consent documents
further_information_received:
subject: We’ve received the additional information you sent us
further_information_requested:
Expand Down
122 changes: 122 additions & 0 deletions spec/mailers/teacher_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
)
end

let(:qualification) { create(:qualification, application_form:) }

describe "#application_awarded" do
subject(:mail) do
described_class.with(application_form:).application_awarded
Expand Down Expand Up @@ -256,6 +258,126 @@
it_behaves_like "an observable mailer", "application_received"
end

describe "#consent_reminder" do
subject(:mail) { described_class.with(application_form:).consent_reminder }

before do
create(
:qualification_request,
:consent_requested,
assessment:,
consent_requested_at: Date.new(2020, 1, 1),
qualification:,
)
end

describe "#subject" do
subject(:subject) { mail.subject }

it do
is_expected.to eq(
"Reminder: we need your written consent to progress your QTS application",
)
end
end

describe "#to" do
subject(:to) { mail.to }

it { is_expected.to eq(["[email protected]"]) }
end

describe "#body" do
subject(:body) { mail.body.encoded }

it { is_expected.to include("Dear First Last") }
it do
is_expected.to include(
"We recently wrote to you asking for your consent",
)
end
it do
is_expected.to include("If you do not send them by 12 February 2020")
end
end

it_behaves_like "an observable mailer", "consent_reminder"
end

describe "#consent_requested" do
subject(:mail) { described_class.with(application_form:).consent_requested }

before do
create(
:qualification_request,
:consent_requested,
assessment:,
consent_requested_at: Date.new(2020, 1, 1),
qualification:,
)
end

describe "#subject" do
subject(:subject) { mail.subject }

it do
is_expected.to eq(
"We need your written consent to progress your QTS application",
)
end
end

describe "#to" do
subject(:to) { mail.to }

it { is_expected.to eq(["[email protected]"]) }
end

describe "#body" do
subject(:body) { mail.body.encoded }

it { is_expected.to include("Dear First Last") }
it do
is_expected.to include(
"As part of your QTS application we need to verify some of your qualifications",
)
end
it do
is_expected.to include("upload these documents by 12 February 2020")
end
end

it_behaves_like "an observable mailer", "consent_requested"
end

describe "#consent_submitted" do
subject(:mail) { described_class.with(application_form:).consent_submitted }

describe "#subject" do
subject(:subject) { mail.subject }

it { is_expected.to eq("We’ve received your consent documents") }
end

describe "#to" do
subject(:to) { mail.to }

it { is_expected.to eq(["[email protected]"]) }
end

describe "#body" do
subject(:body) { mail.body.encoded }

it { is_expected.to include("Dear First Last") }
it do
is_expected.to include("Thank you for submitting the consent documents")
end
it { is_expected.to include("Application reference number: abc") }
end

it_behaves_like "an observable mailer", "consent_submitted"
end

describe "#further_information_received" do
subject(:mail) do
described_class.with(application_form:).further_information_received
Expand Down

0 comments on commit 2d7a605

Please sign in to comment.