Skip to content

Commit

Permalink
Merge pull request #9849 from DFE-Digital/2299-tda-manage-dont-allow-…
Browse files Browse the repository at this point in the history
…providers-to-set-ske-conditions-when-making-an-offer-to-undergraduate-apps

Make sure you can't offer SKE to undergraduate candidates
  • Loading branch information
tomas-stefano authored Sep 20, 2024
2 parents d24cb4a + f2981d1 commit edea368
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/forms/provider_interface/offer_wizard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ def next_step(step = current_step)
end

def ske_required?
language_course? || ske_standard_course? || Array(ske_conditions).any?
!undergraduate_course? && (language_course? || ske_standard_course? || Array(ske_conditions).any?)
end

def undergraduate_course?
course_option&.course&.undergraduate?
end

def language_course?
Expand Down
20 changes: 20 additions & 0 deletions spec/forms/provider_interface/offer_wizard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,26 @@
end
end

context 'when course is undergraduate and current step is :select_option' do
let(:current_step) { :select_option }
let(:course) do
create(
:course,
:teacher_degree_apprenticeship,
subjects: [build(:subject, code: '15', name: 'Portuguese')],
)
end
let(:application_choice) do
create(:application_choice, course_option: create(:course_option, course:))
end
let(:application_choice_id) { application_choice.id }
let(:course_option_id) { application_choice.course_option.id }

it 'returns :conditions' do
expect(wizard.next_step).to eq(:conditions)
end
end

context 'when a ske condition is required' do
let(:ske_conditions) { [SkeCondition.new] }

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

RSpec.describe 'Provider makes an offer on undergraduate applications' do
include DfESignInHelpers
include ProviderUserPermissionsHelper
include OfferStepsHelper
let(:provider) { @provider }
let(:ratifying_provider) { @provider }
let(:provider_user) { @provider_user }
let(:application_choice) { @application_choice }

scenario 'Making an offer for the requested course option' do
given_there_is_an_undergraduate_application
and_the_course_subject_requires_ske
and_i_am_a_provider_user
and_i_am_permitted_to_make_decisions_for_my_provider
and_i_sign_in_to_the_provider_interface

and_the_provider_user_can_offer_multiple_provider_courses
when_i_visit_the_provider_interface
and_i_click_an_application_choice_awaiting_decision
and_i_click_on_make_decision
then_i_see_the_decision_page

when_i_choose_to_make_an_offer
then_the_ske_questions_are_skipped
then_the_conditions_page_is_loaded
and_the_default_conditions_are_checked

when_i_add_further_conditions
and_i_add_and_remove_another_condition
and_i_click_continue
then_the_review_page_is_loaded
and_i_can_confirm_my_answers

when_i_send_the_offer
then_i_see_that_the_offer_was_successfuly_made
end

def given_there_is_an_undergraduate_application
@provider_user = create(:provider_user, :with_dfe_sign_in)
@provider = @provider_user.providers.first
@ratifying_provider = create(:provider)
course = build(:course, :teacher_degree_apprenticeship, provider: @provider, accredited_provider: @ratifying_provider)
course_option = build(:course_option, course:)
@application_choice = create(:application_choice, :awaiting_provider_decision, course_option:)
end

def and_the_course_subject_requires_ske
@application_choice.course_option.course.subjects.delete_all
@application_choice.course_option.course.subjects << build(
:subject, code: 'F1', name: 'Chemistry'
)
end

def and_i_am_a_provider_user
user_exists_in_dfe_sign_in(email_address: @provider_user.email_address)
end

def and_the_provider_user_can_offer_multiple_provider_courses
create(
:provider_relationship_permissions,
training_provider: @provider,
ratifying_provider: @ratifying_provider,
ratifying_provider_can_make_decisions: true,
)
end

def then_the_ske_questions_are_skipped
expect(page).to have_no_content('SKE')
end
end

0 comments on commit edea368

Please sign in to comment.