From 343fb276109d79385f88e34344f95b0d4f5a0cab Mon Sep 17 00:00:00 2001 From: Tomas D'Stefano Date: Tue, 21 May 2024 09:10:59 +0100 Subject: [PATCH] Add course length default value There was two options: Use FourYears like a enumerator or free text. After giving too much thought I opt-in for free text as this will unlikely to change in content --- app/services/courses/creation_service.rb | 2 ++ spec/features/publish/courses/new_tda_course_spec.rb | 2 ++ spec/services/courses/creation_service_spec.rb | 2 ++ 3 files changed, 6 insertions(+) diff --git a/app/services/courses/creation_service.rb b/app/services/courses/creation_service.rb index 08421a023c..a4116541db 100644 --- a/app/services/courses/creation_service.rb +++ b/app/services/courses/creation_service.rb @@ -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:) diff --git a/spec/features/publish/courses/new_tda_course_spec.rb b/spec/features/publish/courses/new_tda_course_spec.rb index 4e5010a858..2c5ae361e4 100644 --- a/spec/features/publish/courses/new_tda_course_spec.rb +++ b/spec/features/publish/courses/new_tda_course_spec.rb @@ -311,6 +311,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 diff --git a/spec/services/courses/creation_service_spec.rb b/spec/services/courses/creation_service_spec.rb index 8fd0b4e43b..c8b46f8830 100644 --- a/spec/services/courses/creation_service_spec.rb +++ b/spec/services/courses/creation_service_spec.rb @@ -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