diff --git a/app/mailers/referee_mailer.rb b/app/mailers/referee_mailer.rb index 5bfcc117064..0abed9188b2 100644 --- a/app/mailers/referee_mailer.rb +++ b/app/mailers/referee_mailer.rb @@ -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 @@ -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 @@ -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 diff --git a/app/views/referee_mailer/reference_request_email.text.erb b/app/views/referee_mailer/reference_request_email.text.erb index ee22d02194b..a40c1e72458 100644 --- a/app/views/referee_mailer/reference_request_email.text.erb +++ b/app/views/referee_mailer/reference_request_email.text.erb @@ -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) %> diff --git a/spec/mailers/referee_mailer_spec.rb b/spec/mailers/referee_mailer_spec.rb index e4eea0185e0..408129ed6ae 100644 --- a/spec/mailers/referee_mailer_spec.rb +++ b/spec/mailers/referee_mailer_spec.rb @@ -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 @@ -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 @@ -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('jane@education.gov.uk') + 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('jane@education.gov.uk') + 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