diff --git a/spec/forms/candidate_interface/course_selection/course_study_mode_step_spec.rb b/spec/forms/candidate_interface/course_selection/course_study_mode_step_spec.rb index 68ae2813b2e..dd7d08029ba 100644 --- a/spec/forms/candidate_interface/course_selection/course_study_mode_step_spec.rb +++ b/spec/forms/candidate_interface/course_selection/course_study_mode_step_spec.rb @@ -19,7 +19,7 @@ end describe '#next_step' do - let(:provider) { create(:provider) } + let(:provider) { create(:provider, selectable_school: true) } let(:course) do create( :course, @@ -42,6 +42,19 @@ end end + context 'when course has multiple sites and provider school is not selectable' do + let(:provider) { create(:provider, selectable_school: false) } + + before do + create(:course_option, site: create(:site, provider:), course:) + create(:course_option, site: create(:site, provider:), course:) + end + + it 'returns :course_review' do + expect(course_study_mode_step.next_step).to be(:course_review) + end + end + context 'when course has single site' do let(:site) { create(:site, provider:) } diff --git a/spec/forms/candidate_interface/course_selection/which_course_are_you_applying_to_step_spec.rb b/spec/forms/candidate_interface/course_selection/which_course_are_you_applying_to_step_spec.rb index ee91d22693a..2b4645579b1 100644 --- a/spec/forms/candidate_interface/course_selection/which_course_are_you_applying_to_step_spec.rb +++ b/spec/forms/candidate_interface/course_selection/which_course_are_you_applying_to_step_spec.rb @@ -4,7 +4,7 @@ subject(:which_course_are_you_applying_to_step) { described_class.new(provider_id:, course_id:, wizard:) } let(:candidate) { create(:candidate) } - let(:provider) { create(:provider) } + let(:provider) { create(:provider, selectable_school: true) } let(:course) do create( :course, @@ -114,7 +114,7 @@ end describe '#next_step' do - let(:provider) { create(:provider) } + let(:provider) { create(:provider, selectable_school: true) } let(:course) do create( :course, @@ -163,6 +163,19 @@ end end + context 'when course has multiple sites and provider school is not selectable' do + let(:provider) { create(:provider, selectable_school: false) } + + before do + create(:course_option, site: create(:site, provider:), course:) + create(:course_option, site: create(:site, provider:), course:) + end + + it 'returns :course_review' do + expect(which_course_are_you_applying_to_step.next_step).to be(:course_review) + end + end + context 'when course has no course availability' do it 'returns :full_course_selection' do expect(which_course_are_you_applying_to_step.next_step).to be(:full_course_selection) 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 new file mode 100644 index 00000000000..432fd841e11 --- /dev/null +++ b/spec/system/candidate_interface/course_selection/candidate_selecting_a_course_with_multiple_sites_and_unselectable_school_spec.rb @@ -0,0 +1,93 @@ +require 'rails_helper' + +RSpec.describe 'Selecting a course with multiple sites when the provider is not selectable_school' do + include CandidateHelper + + it 'Candidate skips the school selection' do + given_i_am_signed_in + and_there_are_course_options + + when_i_visit_the_site + and_i_click_on_course_choices + + and_i_choose_that_i_know_where_i_want_to_apply + and_i_click_continue + and_i_choose_a_provider + and_i_choose_a_course + + then_i_am_on_the_application_choice_review_page + end + + def given_i_am_signed_in + create_and_sign_in_candidate + end + + def when_i_visit_the_site + visit candidate_interface_continuous_applications_details_path + end + + def and_i_click_on_course_choices + click_link_or_button 'Your application' + click_link_or_button 'Add application' + end + + def and_i_choose_that_i_know_where_i_want_to_apply + choose 'Yes, I know where I want to apply' + and_i_click_continue + end + + def when_i_choose_that_i_know_where_i_want_to_apply + and_i_choose_that_i_know_where_i_want_to_apply + end + + def and_i_choose_a_provider + select 'Gorse SCITT (1N1)' + click_link_or_button t('continue') + end + + def and_i_choose_a_course + choose 'Primary (2XT2)' + click_link_or_button t('continue') + end + + def when_i_click_continue + click_link_or_button t('continue') + end + + def and_i_click_continue + when_i_click_continue + end + + def application_choice + current_candidate.current_application.application_choices.last + end + + def and_there_are_course_options + @provider = create(:provider, name: 'Gorse SCITT', code: '1N1', selectable_school: false) + first_site = create( + :site, + name: 'Main site', + code: '-', + provider: @provider, + address_line1: 'Gorse SCITT', + address_line2: 'C/O The Bruntcliffe Academy', + address_line3: 'Bruntcliffe Lane', + address_line4: 'MORLEY, lEEDS', + postcode: 'LS27 0LZ', + ) + second_site = create( + :site, + name: 'Harehills Primary School', + code: '1', + provider: @provider, + address_line1: 'Darfield Road', + address_line2: '', + address_line3: 'Leeds', + address_line4: 'West Yorkshire', + postcode: 'LS8 5DQ', + ) + @multi_site_course = create(:course, :open, :with_both_study_modes, name: 'Primary', code: '2XT2', provider: @provider) + create(:course_option, site: first_site, course: @multi_site_course) + create(:course_option, site: second_site, course: @multi_site_course) + end +end diff --git a/spec/system/candidate_interface/course_selection/candidate_selecting_a_course_with_multiple_study_modes_sites_and_unselectable_school_spec.rb b/spec/system/candidate_interface/course_selection/candidate_selecting_a_course_with_multiple_study_modes_sites_and_unselectable_school_spec.rb new file mode 100644 index 00000000000..b44c4ed1450 --- /dev/null +++ b/spec/system/candidate_interface/course_selection/candidate_selecting_a_course_with_multiple_study_modes_sites_and_unselectable_school_spec.rb @@ -0,0 +1,101 @@ +require 'rails_helper' + +RSpec.describe 'Selecting a course with multiple study modes and sites when the provider is not selectable_school' do + include CandidateHelper + + it 'Candidate skips the school selection' do + given_i_am_signed_in + and_there_are_course_options + + when_i_visit_the_site + and_i_click_on_course_choices + + and_i_choose_that_i_know_where_i_want_to_apply + and_i_click_continue + and_i_choose_a_provider + and_i_choose_a_course + and_i_choose_part_time + + then_i_am_on_the_application_choice_review_page + end + + def given_i_am_signed_in + create_and_sign_in_candidate + end + + def when_i_visit_the_site + visit candidate_interface_continuous_applications_details_path + end + + def and_i_click_on_course_choices + click_link_or_button 'Your application' + click_link_or_button 'Add application' + end + + def and_i_choose_that_i_know_where_i_want_to_apply + choose 'Yes, I know where I want to apply' + and_i_click_continue + end + + def when_i_choose_that_i_know_where_i_want_to_apply + and_i_choose_that_i_know_where_i_want_to_apply + end + + def and_i_choose_a_provider + select 'Gorse SCITT (1N1)' + click_link_or_button t('continue') + end + + def and_i_choose_a_course + choose 'Primary (2XT2)' + click_link_or_button t('continue') + end + + def and_i_choose_part_time + choose 'Part time' + click_link_or_button t('continue') + end + + def when_i_click_continue + click_link_or_button t('continue') + end + + def and_i_click_continue + when_i_click_continue + end + + def application_choice + current_candidate.current_application.application_choices.last + end + + def and_there_are_course_options + @provider = create(:provider, name: 'Gorse SCITT', code: '1N1', selectable_school: false) + first_site = create( + :site, + name: 'Main site', + code: '-', + provider: @provider, + address_line1: 'Gorse SCITT', + address_line2: 'C/O The Bruntcliffe Academy', + address_line3: 'Bruntcliffe Lane', + address_line4: 'MORLEY, lEEDS', + postcode: 'LS27 0LZ', + ) + second_site = create( + :site, + name: 'Harehills Primary School', + code: '1', + provider: @provider, + address_line1: 'Darfield Road', + address_line2: '', + address_line3: 'Leeds', + address_line4: 'West Yorkshire', + postcode: 'LS8 5DQ', + ) + @multi_site_course = create(:course, :open, :with_both_study_modes, name: 'Primary', code: '2XT2', provider: @provider) + create(:course_option, site: first_site, course: @multi_site_course, study_mode: :part_time) + create(:course_option, site: first_site, course: @multi_site_course, study_mode: :full_time) + create(:course_option, site: second_site, course: @multi_site_course, study_mode: :part_time) + create(:course_option, site: second_site, course: @multi_site_course, study_mode: :full_time) + end +end