From 3fab9c58e4e12bcbaec7fa9431b7cdebbf31d299 Mon Sep 17 00:00:00 2001 From: Iain McNulty Date: Thu, 29 Aug 2024 13:21:14 +0100 Subject: [PATCH] Set Choice#placement_school_auto_selected for Provider#selectable_school When a Candidate chooses a course from a provider that has `selectable_school` set to false, we need to record that that candidate did not have the option to choose the placement school. --- .../candidate_interface/application_review_component.rb | 2 ++ .../candidate_interface/course_selection_store.rb | 8 ++++++-- spec/factories/application_choice.rb | 2 ++ .../candidate_selecting_a_course_study_mode_spec.rb | 5 +++++ ...se_with_multiple_sites_and_unselectable_school_spec.rb | 5 +++++ 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/components/candidate_interface/application_review_component.rb b/app/components/candidate_interface/application_review_component.rb index e99c2b1db3b..9d24cc7aeae 100644 --- a/app/components/candidate_interface/application_review_component.rb +++ b/app/components/candidate_interface/application_review_component.rb @@ -95,6 +95,8 @@ def study_mode_row end def location_row + return if application_choice.school_placement_auto_selected? + { key: 'Location', value: current_course_option.site_name, diff --git a/app/services/candidate_interface/course_selection_store.rb b/app/services/candidate_interface/course_selection_store.rb index 5756897dce1..04c1382ef7b 100644 --- a/app/services/candidate_interface/course_selection_store.rb +++ b/app/services/candidate_interface/course_selection_store.rb @@ -40,8 +40,12 @@ def available_course_options end def save_application_choice(choice) - choice.tap do - choice.configure_initial_course_choice!(course_option) + choice.tap do |c| + c.configure_initial_course_choice!(course_option) + + if choice.provider + choice.update(school_placement_auto_selected: !choice.provider.selectable_school?) + end end end end diff --git a/spec/factories/application_choice.rb b/spec/factories/application_choice.rb index c16ae5617f6..3ec7f3d9025 100644 --- a/spec/factories/application_choice.rb +++ b/spec/factories/application_choice.rb @@ -24,6 +24,8 @@ ) end + school_placement_auto_selected { false } + current_recruitment_cycle_year { recruitment_cycle_year || course_option.course.recruitment_cycle_year } personal_statement { Faker::Lorem.paragraph_by_chars(number: 50) } original_course_option { course_option } diff --git a/spec/system/candidate_interface/course_selection/candidate_selecting_a_course_study_mode_spec.rb b/spec/system/candidate_interface/course_selection/candidate_selecting_a_course_study_mode_spec.rb index fe543eacc91..7ce26264568 100644 --- a/spec/system/candidate_interface/course_selection/candidate_selecting_a_course_study_mode_spec.rb +++ b/spec/system/candidate_interface/course_selection/candidate_selecting_a_course_study_mode_spec.rb @@ -17,6 +17,7 @@ when_i_select_the_single_site_full_time_course and_i_visit_my_course_choices_page then_the_site_is_resolved_automatically_and_i_see_the_course_choice + and_the_application_is_not_school_placement_auto_selected end def given_i_am_signed_in @@ -154,4 +155,8 @@ def application_choice def then_i_see_the_provider_name_in_caption expect(page.first('.govuk-caption-xl').text).to eq('University of Alien Dance') end + + def and_the_application_is_not_school_placement_auto_selected + expect(page).to have_content('Location') + end end diff --git a/spec/system/candidate_interface/course_selection/candidate_selecting_a_course_with_multiple_sites_and_unselectable_school_spec.rb b/spec/system/candidate_interface/course_selection/candidate_selecting_a_course_with_multiple_sites_and_unselectable_school_spec.rb index 4621f8646cb..a197ea424e6 100644 --- a/spec/system/candidate_interface/course_selection/candidate_selecting_a_course_with_multiple_sites_and_unselectable_school_spec.rb +++ b/spec/system/candidate_interface/course_selection/candidate_selecting_a_course_with_multiple_sites_and_unselectable_school_spec.rb @@ -16,6 +16,7 @@ and_i_choose_a_course then_i_am_on_the_application_choice_review_page + and_the_application_is_school_placement_auto_selected end def given_i_am_signed_in @@ -90,4 +91,8 @@ def and_there_are_course_options create(:course_option, site: first_site, course: @multi_site_course) create(:course_option, site: second_site, course: @multi_site_course) end + + def and_the_application_is_school_placement_auto_selected + expect(page).to have_no_content('Location') + end end