diff --git a/app/components/candidate_interface/editable_section_warning.html.erb b/app/components/candidate_interface/editable_section_warning.html.erb index 0abcd9349f6..7194ae455c6 100644 --- a/app/components/candidate_interface/editable_section_warning.html.erb +++ b/app/components/candidate_interface/editable_section_warning.html.erb @@ -1,7 +1,9 @@
<% if @section_policy.personal_statement? %> - Any changes you make to your personal statement will not be included in applications you have already submitted. + <%= t('editable_section_warning.personal_statement') %> + <% elsif @section_policy.work_history? %> + <%= t('editable_section_warning.work_history') %> <% else %> - Any changes you make will be included in applications you have already submitted. + <%= t('editable_section_warning.default') %> <% end %>
diff --git a/app/services/candidate_interface/section_policy.rb b/app/services/candidate_interface/section_policy.rb index b8e5e3ba798..545521b7029 100644 --- a/app/services/candidate_interface/section_policy.rb +++ b/app/services/candidate_interface/section_policy.rb @@ -24,6 +24,15 @@ def personal_statement? @controller_path.classify.eql?('CandidateInterface::PersonalStatement') end + def work_history? + controllers = [ + 'CandidateInterface::RestructuredWorkHistory::Review', + 'CandidateInterface::Volunteering::Review', + ] + + controllers.include?(@controller_path.classify) + end + private delegate :any_offer_accepted?, to: :current_application diff --git a/config/application.rb b/config/application.rb index 7a20a63aff5..5b8c9ae9d20 100644 --- a/config/application.rb +++ b/config/application.rb @@ -114,6 +114,8 @@ class Application < Rails::Application becoming_a_teacher science_gcse efl + work_history + volunteering ] config.x.sections.editable_window_days = 5 end diff --git a/config/locales/components/candidate_interface/editable_section_warning.yml b/config/locales/components/candidate_interface/editable_section_warning.yml new file mode 100644 index 00000000000..2c5f853ca41 --- /dev/null +++ b/config/locales/components/candidate_interface/editable_section_warning.yml @@ -0,0 +1,5 @@ +en: + editable_section_warning: + personal_statement: Any changes you make to your personal statement will not be included in applications you have already submitted. + default: Any changes you make will be included in applications you have already submitted. + work_history: Any changes you make will not be included in applications you have already submitted. diff --git a/spec/factories/application_volunteering_experience.rb b/spec/factories/application_volunteering_experience.rb index 960edf65912..2a65eb56268 100644 --- a/spec/factories/application_volunteering_experience.rb +++ b/spec/factories/application_volunteering_experience.rb @@ -1,6 +1,7 @@ FactoryBot.define do factory :application_volunteering_experience do role { ['Teacher', 'Teaching Assistant'].sample } + currently_working { true } organisation { Faker::Educator.secondary_school } details { Faker::Lorem.paragraph_by_chars(number: 300) } working_with_children { [true, true, true, false].sample } diff --git a/spec/services/candidate_interface/section_policy_spec.rb b/spec/services/candidate_interface/section_policy_spec.rb index 63b8771fa7f..ef9629d3f5e 100644 --- a/spec/services/candidate_interface/section_policy_spec.rb +++ b/spec/services/candidate_interface/section_policy_spec.rb @@ -49,6 +49,22 @@ expect(section_policy.can_edit?).to be false end end + + context 'when accessing work history' do + let(:controller_path) { 'candidate_interface/restructured_work_history/review' } + + it 'returns true' do + expect(section_policy.can_edit?).to be true + end + end + + context 'when accessing volunteering experiences' do + let(:controller_path) { 'candidate_interface/volunteering/review' } + + it 'returns true' do + expect(section_policy.can_edit?).to be true + end + end end context 'when candidates already submitted and adds a primary course choice and visits science GCSE' do @@ -258,4 +274,30 @@ end end end + + describe '#work_history?' do + context 'with work_history controller' do + let(:controller_path) { 'candidate_interface/restructured_work_history/review' } + + it 'returns true' do + expect(section_policy.work_history?).to be true + end + end + + context 'with volinteering experiences controller' do + let(:controller_path) { 'candidate_interface/volunteering/review' } + + it 'returns true' do + expect(section_policy.work_history?).to be true + end + end + + context 'without work history controllers' do + let(:controller_path) { 'candidate_interface/personal_details/review' } + + it 'returns true' do + expect(section_policy.work_history?).to be false + end + end + end end diff --git a/spec/system/candidate_interface/entering_details/candidate_can_edit_some_sections_after_first_submission_spec.rb b/spec/system/candidate_interface/entering_details/candidate_can_edit_some_sections_after_first_submission_spec.rb index 536b70b440b..a6aba07d5cd 100644 --- a/spec/system/candidate_interface/entering_details/candidate_can_edit_some_sections_after_first_submission_spec.rb +++ b/spec/system/candidate_interface/entering_details/candidate_can_edit_some_sections_after_first_submission_spec.rb @@ -19,6 +19,8 @@ TestSection.new(:interview_availability, 'Interview availability'), TestSection.new(:equality_and_diversity_information, 'Equality and diversity questions'), TestSection.new(:personal_statement, 'Your personal statement'), + TestSection.new(:work_history, 'Work history'), + TestSection.new(:unpaid_experience, 'Unpaid experience'), ].each do |section| scenario "candidate can edit section '#{section.title}' after submission" do @section = section @@ -35,7 +37,14 @@ end def given_i_already_have_one_submitted_application - application_form = create(:application_form, :completed, candidate: current_candidate) + application_form = create( + :application_form, + :completed, + candidate: current_candidate, + volunteering_experiences_count: 1, + full_work_history: true, + work_history_status: :can_complete, + ) create(:application_choice, :awaiting_provider_decision, application_form:) end @@ -132,6 +141,34 @@ def and_i_can_edit_the_section_personal_statement expect(current_candidate.current_application.reload.becoming_a_teacher).to eq('Repellat qui et') end + def and_i_can_edit_the_section_work_history + work_experience = current_candidate.current_application.application_work_experiences.first + work_break = current_candidate.current_application.application_work_history_breaks.first + click_link_or_button "Change job #{work_experience.role} for #{work_experience.organisation}" + fill_in 'Name of employer', with: 'New employer' + when_i_save_and_continue + + click_link_or_button( + 'Change entry for break between ' \ + "#{work_break.start_date.to_fs(:short_month_and_year)} and " \ + "#{work_break.end_date.to_fs(:short_month_and_year)}", + ) + fill_in 'Enter reasons for break in work history', with: 'New reason' + when_i_click_continue + + expect(work_experience.reload.organisation).to eq('New employer') + expect(work_break.reload.reason).to eq('New reason') + end + + def and_i_can_edit_the_section_unpaid_experience + volunteering = current_candidate.current_application.application_volunteering_experiences.first + click_link_or_button "Change role for #{volunteering.role}, #{volunteering.organisation}" + fill_in 'Your role', with: 'New role' + when_i_save_and_continue + + expect(volunteering.reload.role).to eq('New role') + end + def section_status page.find(:xpath, "//a[contains(text(),'#{@section.title}')]/..").text end diff --git a/spec/system/candidate_interface/entering_details/candidate_can_not_edit_some_sections_after_first_submission_spec.rb b/spec/system/candidate_interface/entering_details/candidate_can_not_edit_some_sections_after_first_submission_spec.rb index db630153205..b1e20cbf41a 100644 --- a/spec/system/candidate_interface/entering_details/candidate_can_not_edit_some_sections_after_first_submission_spec.rb +++ b/spec/system/candidate_interface/entering_details/candidate_can_not_edit_some_sections_after_first_submission_spec.rb @@ -16,8 +16,6 @@ NonEditableSection.new(:degree, 'Degree'), NonEditableSection.new(:references, 'References to be requested if you accept an offer'), NonEditableSection.new(:safeguarding, 'Declare any safeguarding issues'), - NonEditableSection.new(:work_history, 'Work history'), - NonEditableSection.new(:unpaid_experience, 'Unpaid experience'), ].each do |section| scenario "candidate can not edit section '#{section.title}' after submission" do @section = section diff --git a/spec/system/candidate_interface/entering_details/restructured_work_history/candidate_cannot_add_jobs_if_they_have_a_submitted_application_spec.rb b/spec/system/candidate_interface/entering_details/restructured_work_history/candidate_can_add_jobs_if_they_have_a_submitted_application_spec.rb similarity index 78% rename from spec/system/candidate_interface/entering_details/restructured_work_history/candidate_cannot_add_jobs_if_they_have_a_submitted_application_spec.rb rename to spec/system/candidate_interface/entering_details/restructured_work_history/candidate_can_add_jobs_if_they_have_a_submitted_application_spec.rb index c94246b05c8..406f3fcd1ba 100644 --- a/spec/system/candidate_interface/entering_details/restructured_work_history/candidate_cannot_add_jobs_if_they_have_a_submitted_application_spec.rb +++ b/spec/system/candidate_interface/entering_details/restructured_work_history/candidate_can_add_jobs_if_they_have_a_submitted_application_spec.rb @@ -3,12 +3,12 @@ RSpec.describe 'Trying to enter work history' do include CandidateHelper - scenario 'Candidate does not see Add job or Add another job buttons' do + scenario 'Candidate does see Add job or Add another job buttons' do given_i_am_signed_in and_i_have_completed_work_history and_i_have_a_submitted_application when_i_view_work_history - then_i_do_not_see_an_option_to_add_another_job + then_i_do_see_an_option_to_add_another_job end def given_i_am_signed_in @@ -31,9 +31,8 @@ def and_i_have_a_submitted_application create(:application_choice, :awaiting_provider_decision, application_form: @application_form_can_complete_work_history) end - def then_i_do_not_see_an_option_to_add_another_job + def then_i_do_see_an_option_to_add_another_job expect(page).to have_content 'Work history' - expect(page).to have_no_content 'Add another job' - expect(page).to have_no_content 'Add job' + expect(page).to have_content 'Add another job' end end