Skip to content

Commit

Permalink
Add specs for unseleactable school
Browse files Browse the repository at this point in the history
  We test the case where the course has multiple sites but the provider
  is selectable school false.

  Test for courses with and without multiple study modes
  • Loading branch information
inulty-dfe committed Aug 29, 2024
1 parent 37e68da commit a495af1
Show file tree
Hide file tree
Showing 4 changed files with 223 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a495af1

Please sign in to comment.