Skip to content

Commit

Permalink
Interrupt the candidate post-offer when adding a reference
Browse files Browse the repository at this point in the history
If a candidate has accepted an offer, they can add another reference. If they add one with a personal email address, they should be interrupted.
  • Loading branch information
elceebee committed Nov 5, 2024
1 parent 19eaf6d commit 438f689
Show file tree
Hide file tree
Showing 2 changed files with 159 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ class RequestReference::EmailAddressController < EmailAddressController
include RequestReferenceOfferDashboard

def next_path
candidate_interface_request_reference_references_relationship_path(
@reference.id,
)
if @reference_email_address_form.personal_email_address?(@reference)
return_to_params = return_to_request_reference_review? ? { return_to: 'request-reference-review' } : nil
candidate_interface_request_reference_references_interruption_path(
@reference.id, params: return_to_params
)
else
return_to_path ||
candidate_interface_request_reference_references_relationship_path(@reference.id)
end
end

def set_email_address_form
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
require 'rails_helper'

RSpec.describe 'Creating references with personal email addresses after an offer has been accepted' do
include CandidateHelper

scenario 'Candidate adds a new reference and see personal email address interruption' do
given_i_am_signed_in
and_i_have_an_accepted_offer
and_i_navigate_to_add_another_reference
and_i_complete_some_reference_details

when_i_provide_an_email_that_appears_to_be_personal
then_i_see_the_interruption

when_i_click_go_back_and_change
and_i_provide_a_work_email_address
then_i_see_the_relationship_page_not_the_interruption

when_i_complete_my_references_details
then_i_see_my_reference_with_professional_email_address
end

scenario 'Candidate saves a new reference and with personal email address' do
given_i_am_signed_in
and_i_have_an_accepted_offer
and_i_navigate_to_add_another_reference
and_i_complete_some_reference_details
when_i_provide_an_email_that_appears_to_be_personal
then_i_see_the_interruption

when_i_choose_to_continue_with_the_personal_email_address
then_i_see_the_relationship_page_not_the_interruption

when_i_complete_my_references_details
then_i_see_my_reference_with_personal_email_address
end

scenario 'Candidate changes personal email address at interruption with back buttons' do
given_i_am_signed_in
and_i_have_an_accepted_offer
and_i_navigate_to_add_another_reference
and_i_complete_some_reference_details
when_i_provide_an_email_that_appears_to_be_personal
then_i_see_the_interruption

when_i_click_back
and_i_provide_a_work_email_address
then_i_see_the_relationship_page_not_the_interruption

when_i_complete_my_references_details
then_i_see_my_reference_with_professional_email_address
end

private

def given_i_am_signed_in
@candidate = create(:candidate)
login_as(@candidate)
@application_form = create(:completed_application_form, candidate: @candidate)
end

def and_i_have_an_accepted_offer
@application_form = create(:completed_application_form, candidate: @candidate)
@pending_reference = create(:reference, :feedback_requested, reminder_sent_at: nil, application_form: @application_form)
@completed_reference = create(:reference, :feedback_provided, application_form: @application_form)

@application_choice = create(
:application_choice,
:accepted,
application_form: @application_form,
)
end

def and_i_navigate_to_add_another_reference
visit root_path
click_on 'Request another reference'
click_on 'Continue'
end

def and_i_complete_some_reference_details
choose 'Academic, such as a university tutor'
click_on 'Continue'
fill_in 'What’s the name of the person who can give a reference?', with: 'Walter White'
click_on 'Save and continue'
end

def when_i_click_add_reference
click_on 'Add reference'
end

def when_i_provide_an_email_that_appears_to_be_personal
fill_in 'What is Walter White’s email address?', with: '[email protected]'
click_on 'Save and continue'
end

def and_i_provide_a_work_email_address
fill_in 'What is Walter White’s email address?', with: '[email protected]'
end

def when_i_click_go_back_and_change
click_on 'Go back and change the email address'
end

def when_i_click_back
click_on 'Back'
end

def then_i_see_the_interruption
expect(page).to have_content '[email protected] looks like a personal email address'
expect(page).to have_content 'You should ask Walter White if they have a work email address you can use instead and update your application.'
end

def then_i_see_the_relationship_page_not_the_interruption
expect(page).to have_current_path candidate_interface_request_reference_references_relationship_path(@application_form.application_references.creation_order.last.id)
expect(page).to have_content 'How do you know Walter White and how long have you known them?'
expect(page).to have_no_content 'You should ask Walter White if they have a work email address you can use instead and update your application.'
end

def when_i_choose_to_continue_with_the_personal_email_address
click_on 'Save and continue'
end

def when_i_complete_my_references_details
fill_in 'How do you know Walter White and how long have you known them?', with: 'They were my course supervisor.'
click_on 'Save and continue'
end

def and_i_provide_a_work_email_address
fill_in 'What is Walter White’s email address?', with: '[email protected]'
click_on 'Save and continue'
end

def then_i_see_my_reference_with_professional_email_address
expect(page).to have_content('Academic, such as a university tutor')
expect(page).to have_content('Walter White')
expect(page).to have_content('[email protected]')
expect(page).to have_content('They were my course supervisor.')
end

def then_i_see_my_reference_with_personal_email_address
expect(page).to have_content('Academic, such as a university tutor')
expect(page).to have_content('Walter White')
expect(page).to have_content('[email protected]')
expect(page).to have_content('They were my course supervisor.')
end

def and_i_click_request_another_reference
click_on 'Request another reference'
end
end

0 comments on commit 438f689

Please sign in to comment.