Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[445] Update referee emails to include confidentiality statement #10291

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
avinhurry marked this conversation as resolved.
Show resolved Hide resolved
@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
Loading