Skip to content

Commit

Permalink
Don't show the TDA option when the course is non TDA and published
Browse files Browse the repository at this point in the history
Also hide the change outcome links when the course is TDA and published
  • Loading branch information
tomas-stefano committed Jul 11, 2024
1 parent a0862ee commit 7981a2a
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 4 deletions.
4 changes: 4 additions & 0 deletions app/decorators/course_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/views/publish/courses/_basic_details_tab.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
57 changes: 57 additions & 0 deletions spec/decorators/course_decorator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)])])
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down
35 changes: 35 additions & 0 deletions spec/models/concerns/courses/edit_options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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
Expand Down

0 comments on commit 7981a2a

Please sign in to comment.