diff --git a/app/decorators/course_decorator.rb b/app/decorators/course_decorator.rb index 1ba74b0621..23d8194c4a 100644 --- a/app/decorators/course_decorator.rb +++ b/app/decorators/course_decorator.rb @@ -454,6 +454,10 @@ def show_degree_requirements_row? !teacher_degree_apprenticeship? end + def immutable_course_outcome? + (object.teacher_degree_apprenticeship? && object.is_published?) || object.is_withdrawn? + end + private def not_on_find diff --git a/app/models/concerns/courses/edit_options/qualification_concern.rb b/app/models/concerns/courses/edit_options/qualification_concern.rb index 0d4fcd7e5c..2c85571ae8 100644 --- a/app/models/concerns/courses/edit_options/qualification_concern.rb +++ b/app/models/concerns/courses/edit_options/qualification_concern.rb @@ -16,9 +16,13 @@ def qualification_options def qualifications_with_qts qts_list = Course.qualifications.keys.grep(/qts/) - return qts_list if tda_active? + qts_list -= %w[undergraduate_degree_with_qts] if !tda_active? || non_tda_published? - qts_list - %w[undergraduate_degree_with_qts] + qts_list + end + + def non_tda_published? + !teacher_degree_apprenticeship? && is_published? end def qualifications_without_qts diff --git a/app/views/publish/courses/_basic_details_tab.html.erb b/app/views/publish/courses/_basic_details_tab.html.erb index 2e43035962..73c30ede00 100644 --- a/app/views/publish/courses/_basic_details_tab.html.erb +++ b/app/views/publish/courses/_basic_details_tab.html.erb @@ -62,7 +62,7 @@ summary_list.with_row(html_attributes: { data: { qa: "course__outcome" } }) do |row| row.with_key { "Qualification" } row.with_value { course.outcome } - if course.is_withdrawn? + if course.immutable_course_outcome? row.with_action else row.with_action( diff --git a/spec/decorators/course_decorator_spec.rb b/spec/decorators/course_decorator_spec.rb index 10742db4b7..52b3f6d83b 100644 --- a/spec/decorators/course_decorator_spec.rb +++ b/spec/decorators/course_decorator_spec.rb @@ -1015,6 +1015,63 @@ end end + describe '#immutable_course_outcome?' do + it 'returns true when the course is a TDA and is published' do + course = create( + :course, + :with_teacher_degree_apprenticeship, + :resulting_in_undergraduate_degree_with_qts, + :with_gcse_equivalency, + :published + ).decorate + + expect(course.immutable_course_outcome?).to be(true) + end + + it 'returns false when the course is a TDA but not published' do + course = create( + :course, + :with_teacher_degree_apprenticeship, + :resulting_in_undergraduate_degree_with_qts, + :with_gcse_equivalency + ).decorate + + expect(course.immutable_course_outcome?).to be(false) + end + + it 'returns false when the course is not a TDA but is published' do + course = create( + :course, + :resulting_in_qts, + :with_gcse_equivalency, + :published + ).decorate + + expect(course.immutable_course_outcome?).to be(false) + end + + it 'returns true when the course is withdrawn' do + course = create( + :course, + :resulting_in_qts, + :with_gcse_equivalency, + :withdrawn + ).decorate + + expect(course.immutable_course_outcome?).to be(true) + end + + it 'returns false when the course is not a TDA, not published, and not withdrawn' do + course = create( + :course, + :resulting_in_qts, + :with_gcse_equivalency + ).decorate + + expect(course.immutable_course_outcome?).to be(false) + end + end + describe '#financial_incentive_details' do subject { course.decorate.financial_incentive_details } diff --git a/spec/features/publish/courses/publishing_a_teacher_degree_apprenticeship_course_with_validation_errors_spec.rb b/spec/features/publish/courses/publishing_a_teacher_degree_apprenticeship_course_with_validation_errors_spec.rb index 244e441815..9bcf7245f3 100644 --- a/spec/features/publish/courses/publishing_a_teacher_degree_apprenticeship_course_with_validation_errors_spec.rb +++ b/spec/features/publish/courses/publishing_a_teacher_degree_apprenticeship_course_with_validation_errors_spec.rb @@ -3,9 +3,12 @@ require 'rails_helper' feature 'Publishing courses errors', { can_edit_current_and_next_cycles: false } do - scenario 'The error links target the correct pages' do + before do given_i_am_authenticated_as_a_provider_user and_the_tda_feature_flag_is_active + end + + scenario 'The error links target the correct pages' do and_there_is_an_invalid_tda_course_i_want_to_publish when_i_visit_the_course_page @@ -45,6 +48,22 @@ then_the_course_is_published end + scenario 'when the TDA course is published and I try to change qualification' do + given_there_is_an_published_tda_course + when_i_visit_the_course_page + and_i_enter_the_basic_details_tab + then_there_is_no_change_qualification_link + end + + scenario 'when the non TDA course is published and I try to change qualification' do + given_there_is_an_published_qts_course + when_i_visit_the_course_page + and_i_enter_the_basic_details_tab + and_i_click_change_qualification + then_the_tda_option_is_not_available + and_i_on_the_change_qualification_page + end + def given_i_am_authenticated_as_a_provider_user recruitment_cycle = create(:recruitment_cycle, year: 2025) @user = create(:user, providers: [build(:provider, recruitment_cycle:, provider_type: 'lead_school', sites: [build(:site), build(:site)], study_sites: [build(:site, :study_site), build(:site, :study_site)])]) @@ -82,6 +101,34 @@ def and_there_is_an_invalid_tda_course_i_want_to_publish @course.sites << build_list(:site, 1, provider: @provider) end + def given_there_is_an_published_tda_course + @course = create( + :course, + :with_teacher_degree_apprenticeship, + :resulting_in_undergraduate_degree_with_qts, + :with_gcse_equivalency, + :published, + provider: @provider, + accrediting_provider: @accredited_provider, + a_level_subject_requirements: [], + accept_pending_a_level: nil, + accept_a_level_equivalency: nil + ) + @course.sites << build_list(:site, 1, provider: @provider) + end + + def given_there_is_an_published_qts_course + @course = create( + :course, + :resulting_in_qts, + :with_gcse_equivalency, + :published, + provider: @provider, + accrediting_provider: @accredited_provider + ) + @course.sites << build_list(:site, 1, provider: @provider) + end + def when_i_visit_the_course_page publish_provider_courses_show_page.load( provider_code: @provider.provider_code, @@ -100,6 +147,32 @@ def then_i_am_on_the_course_page ) end + def then_there_is_no_change_qualification_link + expect(publish_provider_courses_details_page.outcome.actions.text).to be_empty + end + + def and_i_enter_the_basic_details_tab + click_on 'Basic details' + end + + def and_i_click_change_qualification + publish_provider_courses_details_page.outcome.actions.find('a').click + end + + def then_the_tda_option_is_not_available + expect(page).to have_no_field('Teacher degree apprenticeship (TDA) with QTS', type: 'radio') + end + + def and_i_on_the_change_qualification_page + expect(page).to have_current_path( + outcome_publish_provider_recruitment_cycle_course_path( + @course.provider.provider_code, + @course.provider.recruitment_cycle_year, + @course.course_code + ) + ) + end + def and_i_click_the_publish_link publish_provider_courses_show_page.course_button_panel.publish_button.click end diff --git a/spec/models/concerns/courses/edit_options_spec.rb b/spec/models/concerns/courses/edit_options_spec.rb index 8d0a67fe08..e45e97feef 100644 --- a/spec/models/concerns/courses/edit_options_spec.rb +++ b/spec/models/concerns/courses/edit_options_spec.rb @@ -75,6 +75,9 @@ end describe 'qualifications' do + let(:provider) { create(:provider, recruitment_cycle: create(:recruitment_cycle, year: 2025)) } + let(:course) { create(:course, provider:, level: 'primary', subjects: [subjects]) } + context "for a course that's not further education" do it 'returns only QTS options for users to choose between' do expect(course.qualification_options).to eq(%w[qts pgce_with_qts pgde_with_qts]) @@ -95,6 +98,38 @@ end end end + + context 'when TDA is active' do + before do + allow(Settings.features).to receive(:teacher_degree_apprenticeship).and_return(true) + end + + it 'includes undergraduate_degree_with_qts' do + expect(course.qualification_options).to include('undergraduate_degree_with_qts') + end + end + + context 'when TDA is not active' do + before do + allow(Settings.features).to receive(:teacher_degree_apprenticeship).and_return(false) + end + + it 'does not include undergraduate_degree_with_qts' do + expect(course.qualification_options).not_to include('undergraduate_degree_with_qts') + end + end + + context 'when the course is non-TDA and published' do + let(:course) { create(:course, :resulting_in_qts, :published) } + + before do + allow(Settings.features).to receive(:teacher_degree_apprenticeship).and_return(true) + end + + it 'does not include undergraduate_degree_with_qts' do + expect(course.qualification_options).not_to include('undergraduate_degree_with_qts') + end + end end describe 'age_range' do