From ed073a692500cc56725074acff891c9706e39aec Mon Sep 17 00:00:00 2001 From: Tomas D'Stefano Date: Thu, 19 Sep 2024 17:15:01 +0100 Subject: [PATCH 1/2] Make sure you can offer SKE to undergraduate candidates When candidates applying for a undergraduate courses, the provider should not have the option to make a offer with SKE. --- app/forms/provider_interface/offer_wizard.rb | 6 +- .../provider_interface/offer_wizard_spec.rb | 20 ++++++ ...ffer_for_undergraduate_application_spec.rb | 72 +++++++++++++++++++ 3 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 spec/system/provider_interface/make_offer_for_undergraduate_application_spec.rb diff --git a/app/forms/provider_interface/offer_wizard.rb b/app/forms/provider_interface/offer_wizard.rb index 2ad2a8cf9ed..8f961ea8702 100644 --- a/app/forms/provider_interface/offer_wizard.rb +++ b/app/forms/provider_interface/offer_wizard.rb @@ -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? diff --git a/spec/forms/provider_interface/offer_wizard_spec.rb b/spec/forms/provider_interface/offer_wizard_spec.rb index 7d5ef04ef09..0512644246a 100644 --- a/spec/forms/provider_interface/offer_wizard_spec.rb +++ b/spec/forms/provider_interface/offer_wizard_spec.rb @@ -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] } diff --git a/spec/system/provider_interface/make_offer_for_undergraduate_application_spec.rb b/spec/system/provider_interface/make_offer_for_undergraduate_application_spec.rb new file mode 100644 index 00000000000..acb0d3f1933 --- /dev/null +++ b/spec/system/provider_interface/make_offer_for_undergraduate_application_spec.rb @@ -0,0 +1,72 @@ +require 'rails_helper' + +RSpec.describe 'Provider makes an offer with SKE enabled in standard courses' 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 From f2981d16c8b665e7b66864832086a06cc2759144 Mon Sep 17 00:00:00 2001 From: Tomas D'Stefano Date: Thu, 19 Sep 2024 17:20:43 +0100 Subject: [PATCH 2/2] Change test description --- .../make_offer_for_undergraduate_application_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/system/provider_interface/make_offer_for_undergraduate_application_spec.rb b/spec/system/provider_interface/make_offer_for_undergraduate_application_spec.rb index acb0d3f1933..5e3e182cfc7 100644 --- a/spec/system/provider_interface/make_offer_for_undergraduate_application_spec.rb +++ b/spec/system/provider_interface/make_offer_for_undergraduate_application_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe 'Provider makes an offer with SKE enabled in standard courses' do +RSpec.describe 'Provider makes an offer on undergraduate applications' do include DfESignInHelpers include ProviderUserPermissionsHelper include OfferStepsHelper