Skip to content

Commit

Permalink
Merge pull request #10291 from DFE-Digital/445-small-change-to-refere…
Browse files Browse the repository at this point in the history
…nces-emails-to-reflect-confidentiality-changes

[445] Update referee emails to include confidentiality statement
  • Loading branch information
avinhurry authored Jan 22, 2025
2 parents d67406b + ce8ce00 commit 4c115b2
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 53 deletions.
3 changes: 3 additions & 0 deletions app/mailers/referee_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ def reference_request_email(reference)
@application_form = reference.application_form
@reference = reference
@candidate_name = @application_form.full_name
@candidate_first_name = @application_form.first_name
@unhashed_token = reference.refresh_feedback_token!
@referee_type = @reference.referee_type
@provider_name = @application_form.application_choices.select(&:accepted_choice?).first.provider.name
Expand All @@ -20,6 +21,7 @@ def reference_request_chaser_email(application_form, reference)
@application_form = application_form
@reference = reference
@candidate_name = @application_form.full_name
@candidate_first_name = @application_form.first_name
@unhashed_token = reference.refresh_feedback_token!
@referee_type = @reference.referee_type
@provider_name = @application_form.application_choices.select(&:accepted_choice?).first.provider.name
Expand Down Expand Up @@ -59,6 +61,7 @@ def reference_request_chase_again_email(reference)
@application_form = reference.application_form
@reference = reference
@candidate_name = @application_form.full_name
@candidate_first_name = @application_form.first_name
@unhashed_token = reference.refresh_feedback_token!
@referee_type = @reference.referee_type
@provider_name = @application_form.application_choices.select(&:accepted_choice?).first.provider.name
Expand Down
4 changes: 4 additions & 0 deletions app/views/referee_mailer/reference_request_email.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ You will need to:
-say whether you have any concerns about them working with children
-give factual information which can be used to check their application, for example about <%= t("referee_mailer.guidance.#{@referee_type}") %>

<% if FeatureFlag.active?(:show_reference_confidentiality_status) %>
You can choose whether <%= @candidate_first_name %> will be able to see your reference or if it should be kept confidential.
<% end %>

Use this link to give the reference or to say you cannot give one:

<%= referee_interface_url(token: @unhashed_token) %>
Expand Down
160 changes: 107 additions & 53 deletions spec/mailers/referee_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,65 +19,101 @@
it_behaves_like 'mailer previews', RefereeMailerPreview

describe 'Send request reference email' do
let(:email) { mailer.reference_request_email(reference) }
let(:application_choices) { [create(:application_choice, :accepted, course_option:)] }
context 'with confidentiality feature flag active' do
before { FeatureFlag.activate(:show_reference_confidentiality_status) }

it 'sends an email with a link to the reference form' do
expect(email.body).to include('/reference?token=raw_token')
end
let(:email) { mailer.reference_request_email(reference) }
let(:application_choices) { [create(:application_choice, :accepted, course_option:)] }

it 'sends a request with a Notify reference' do
ClimateControl.modify HOSTING_ENVIRONMENT_NAME: 'example_env' do
email.deliver_now
it 'sends an email with a link to the reference form' do
expect(email.body).to include('/reference?token=raw_token')
end

expect(email[:reference].value).to start_with("example_env-reference_request-#{reference.id}")
end
it 'sends a request with a Notify reference' do
ClimateControl.modify HOSTING_ENVIRONMENT_NAME: 'example_env' do
email.deliver_now
end

it_behaves_like(
'a mail with subject and content',
I18n.t('referee_mailer.reference_request.subject', candidate_name: 'Elliot Alderson'),
'heading' => 'Dear Jane',
'details' => 'Elliot Alderson has accepted an offer from University of Warwick for a place on a teacher training course',
'further guidance' => 'whether you have any concerns about them working with children',
)
expect(email[:reference].value).to start_with("example_env-reference_request-#{reference.id}")
end

it 'adds additional guidance for academic references' do
reference.referee_type = :academic
it_behaves_like(
'a mail with subject and content',
'Teacher training reference needed for Elliot Alderson',
'heading' => 'Dear Jane',
'details' => 'Elliot Alderson has accepted an offer from University of Warwick for a place on a teacher training course',
'further guidance' => 'whether you have any concerns about them working with children',
'confidentiality statement' => 'You can choose whether Elliot will be able to see your reference or if it should be kept confidential.',
)

expect(email.body).to include('for example about their academic record')
end
it 'adds additional guidance for academic references' do
reference.referee_type = :academic

expect(email.body).to include('for example about their academic record')
end

it 'adds additional guidance for character references' do
reference.referee_type = :character
it 'adds additional guidance for character references' do
reference.referee_type = :character

expect(email.body).to include('for example about activities you have done together')
expect(email.body).to include('for example about activities you have done together')
end

%i[professional school_based].each do |referee_type|
it "adds additional guidance for #{referee_type} references" do
reference.referee_type = referee_type

expect(email.body).to include('for example about their role and responsibilities at work')
end
end
end

%i[professional school_based].each do |referee_type|
it "adds additional guidance for #{referee_type} references" do
reference.referee_type = referee_type
context 'with confidentiality feature flag inactive' do
before { FeatureFlag.deactivate(:show_reference_confidentiality_status) }

let(:email) { mailer.reference_request_email(reference) }
let(:application_choices) { [create(:application_choice, :accepted, course_option:)] }

expect(email.body).to include('for example about their role and responsibilities at work')
it 'does not include the confidentiality statement' do
expect(email.body).not_to include(
'You can choose whether Elliot will be able to see your reference or if it should be kept confidential.',
)
end
end
end

describe 'Send chasing reference email' do
let(:email) { mailer.reference_request_chaser_email(application_form, reference) }
let(:application_choices) { [create(:application_choice, :accepted, course_option:)] }
context 'with confidentiality feature flag active' do
before { FeatureFlag.activate(:show_reference_confidentiality_status) }

it 'sends an email with a link to the reference form' do
expect(email.body).to include('/reference?token=raw_token')
let(:email) { mailer.reference_request_chaser_email(application_form, reference) }
let(:application_choices) { [create(:application_choice, :accepted, course_option:)] }

it 'sends an email with a link to the reference form' do
expect(email.body).to include('/reference?token=raw_token')
end

it_behaves_like(
'a mail with subject and content',
'Teacher training reference needed for Elliot Alderson',
'heading' => 'Dear Jane',
'details' => 'Elliot Alderson has accepted an offer from University of Warwick for a place on a teacher training course',
'further guidance' => 'whether you have any concerns about them working with children',
'confidentiality statement' => 'You can choose whether Elliot will be able to see your reference or if it should be kept confidential.',
)
end

it_behaves_like(
'a mail with subject and content',
I18n.t('referee_mailer.reference_request.subject', candidate_name: 'Elliot Alderson'),
'heading' => 'Dear Jane',
'details' => 'Elliot Alderson has accepted an offer from University of Warwick for a place on a teacher training course',
'further guidance' => 'whether you have any concerns about them working with children',
)
context 'with confidentiality feature flag inactive' do
before { FeatureFlag.deactivate(:show_reference_confidentiality_status) }

let(:email) { mailer.reference_request_chaser_email(application_form, reference) }
let(:application_choices) { [create(:application_choice, :accepted, course_option:)] }

it 'does not include the confidentiality statement' do
expect(email.body).not_to include(
'You can choose whether Elliot will be able to see your reference or if it should be kept confidential.',
)
end
end
end

describe 'Send reference confirmation email' do
Expand All @@ -89,7 +125,7 @@

it_behaves_like(
'a mail with subject and content',
I18n.t('reference_confirmation_email.subject', candidate_name: 'Elliot Alderson'),
'Teacher training reference submitted for Elliot Alderson',
'heading' => 'Dear Jane',
)
end
Expand All @@ -103,26 +139,44 @@

it_behaves_like(
'a mail with subject and content',
I18n.t('reference_cancelled_email.subject', candidate_name: 'Elliot Alderson'),
'Teacher training reference no longer needed for Elliot Alderson',
'heading' => 'Dear Jane',
)
end

describe 'Send reference_request_chase_again_email email' do
let(:email) { mailer.reference_request_chase_again_email(reference) }
let(:application_choices) { [create(:application_choice, :accepted, course_option:)] }
context 'with confidentiality feature flag active' do
before { FeatureFlag.activate(:show_reference_confidentiality_status) }

it 'sends an email to the provided referee' do
expect(email.to).to include('[email protected]')
let(:email) { mailer.reference_request_chase_again_email(reference) }
let(:application_choices) { [create(:application_choice, :accepted, course_option:)] }

it 'sends an email to the provided referee' do
expect(email.to).to include('[email protected]')
end

it_behaves_like(
'a mail with subject and content',
'Teacher training reference needed for Elliot Alderson',
'heading' => 'Dear Jane',
'reference link' => '/reference?token=raw_token',
'details' => 'Elliot Alderson has accepted an offer from University of Warwick for a place on a teacher training course',
'further guidance' => 'whether you have any concerns about them working with children',
'confidentiality statement' => 'You can choose whether Elliot will be able to see your reference or if it should be kept confidential.',
)
end

it_behaves_like(
'a mail with subject and content',
I18n.t('referee_mailer.reference_request.subject', candidate_name: 'Elliot Alderson'),
'heading' => 'Dear Jane',
'reference link' => '/reference?token=raw_token',
'details' => 'Elliot Alderson has accepted an offer from University of Warwick for a place on a teacher training course',
'further guidance' => 'whether you have any concerns about them working with children',
)
context 'with confidentiality feature flag inactive' do
before { FeatureFlag.deactivate(:show_reference_confidentiality_status) }

let(:email) { mailer.reference_request_chase_again_email(reference) }
let(:application_choices) { [create(:application_choice, :accepted, course_option:)] }

it 'does not include the confidentiality statement' do
expect(email.body).not_to include(
'You can choose whether Elliot will be able to see your reference or if it should be kept confidential.',
)
end
end
end
end

0 comments on commit 4c115b2

Please sign in to comment.