Skip to content

Commit

Permalink
Merge pull request #4221 from DFE-Digital/1675-add-4-year-default-for…
Browse files Browse the repository at this point in the history
…-tda-courses

1675 add 4 year default for tda courses
  • Loading branch information
tomas-stefano authored May 22, 2024
2 parents a44fc42 + c014f6f commit 781a383
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/services/courses/creation_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def build_new_course
course.can_sponsor_student_visa = false
course.can_sponsor_skilled_worker_visa = false
course.degree_grade = 'not_required'
course_enrichment = course.enrichments.find_or_initialize_draft
course_enrichment.course_length = '4 years'
end

AssignSubjectsService.call(course:, subject_ids:)
Expand Down
61 changes: 60 additions & 1 deletion spec/features/publish/courses/new_tda_course_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
when_i_click_on_the_course_description_tab
then_i_do_not_see_the_degree_requirements_row
and_i_do_not_see_the_change_link_for_course_length

given_i_fill_in_all_other_fields_for_the_course
when_i_publish_the_course
then_the_course_is_published
end

scenario 'creating a degree awarding course from scitt provider' do
Expand Down Expand Up @@ -78,6 +82,10 @@
when_i_click_on_the_course_description_tab
then_i_do_not_see_the_degree_requirements_row
and_i_do_not_see_the_change_link_for_course_length

given_i_fill_in_all_other_fields_for_the_course
when_i_publish_the_course
then_the_course_is_published
end

scenario 'when choosing primary course' do
Expand Down Expand Up @@ -113,6 +121,10 @@
when_i_click_on_the_course_description_tab
then_i_do_not_see_the_degree_requirements_row
and_i_do_not_see_the_change_link_for_course_length

given_i_fill_in_all_other_fields_for_the_course
when_i_publish_the_course
then_the_course_is_published
end

scenario 'do not show teacher degree apprenticeship for further education' do
Expand All @@ -129,7 +141,8 @@ def given_i_am_authenticated_as_a_school_direct_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)])])
@provider = @user.providers.first
@accredited_provider = create(:provider, :accredited_provider, recruitment_cycle:)
create(:provider, :accredited_provider, provider_code: '1BJ')
@accredited_provider = create(:provider, :accredited_provider, provider_code: '1BJ', recruitment_cycle:)
@provider.accrediting_provider_enrichments = []
@provider.accrediting_provider_enrichments << AccreditingProviderEnrichment.new(
{
Expand Down Expand Up @@ -311,6 +324,8 @@ def and_the_tda_defaults_are_saved
expect(course.additional_degree_subject_requirements).to be_nil
expect(course.degree_subject_requirements).to be_nil
expect(course.degree_grade).to eq('not_required')
expect(course.enrichments.last).to be_present
expect(course.enrichments.last.course_length).to eq('4 years')
end

def and_i_select_no_send
Expand Down Expand Up @@ -368,6 +383,50 @@ def then_i_do_not_see_the_degree_requirements_row
expect(publish_provider_courses_show_page).not_to have_degree
end

def given_i_fill_in_all_other_fields_for_the_course
and_i_add_course_details
and_i_add_salary_information
and_i_add_gcse_requirements
end

def and_i_add_course_details
publish_provider_courses_show_page.about_course.find_link(
text: 'Change details about this course'
).click
publish_course_information_edit_page.about_course.set('Details about the course')
publish_course_information_edit_page.interview_process.set('Interview process details')
publish_course_information_edit_page.school_placements.set('School placements information')
publish_course_information_edit_page.submit.click
end

def and_i_add_salary_information
publish_provider_courses_show_page.salary_details.find_link(text: 'Change salary').click
publish_course_salary_edit_page.salary_details.set('Some salary details')
publish_course_salary_edit_page.submit.click
end

def and_i_add_gcse_requirements
publish_provider_courses_show_page.gcse.find_link(
text: 'Enter GCSE and equivalency test requirements'
).click
publish_courses_gcse_requirements_page.pending_gcse_yes_radio.click
publish_courses_gcse_requirements_page.gcse_equivalency_yes_radio.click
publish_courses_gcse_requirements_page.english_equivalency.check
publish_courses_gcse_requirements_page.maths_equivalency.check
publish_courses_gcse_requirements_page.additional_requirements.set('Some Proficiency')
publish_courses_gcse_requirements_page.save.click
end

def when_i_publish_the_course
publish_provider_courses_show_page.course_button_panel.publish_button.click
end

def then_the_course_is_published
expect(publish_provider_courses_show_page.errors.map(&:text)).to eq([])
expect(page).to have_content('Your course has been published.')
expect(course.content_status).to be :published
end

def provider
@user.providers.first
end
Expand Down
2 changes: 2 additions & 0 deletions spec/services/courses/creation_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
expect(subject.additional_degree_subject_requirements).to be_nil
expect(subject.degree_subject_requirements).to be_nil
expect(subject.degree_grade).to eq('not_required')
expect(subject.enrichments.last).to be_present
expect(subject.enrichments.last.course_length).to eq('4 years')
end
end

Expand Down

0 comments on commit 781a383

Please sign in to comment.