From 93952d952dac3207ef07b481e1f24894e3698742 Mon Sep 17 00:00:00 2001 From: Avin Hurry Date: Mon, 9 Sep 2024 11:11:37 +0100 Subject: [PATCH 1/2] [2280] Update usages of course_type to degree_type --- .../find/search/visa_status_controller.rb | 6 ++-- .../publish/courses/outcome_controller.rb | 2 +- app/models/course.rb | 8 ++--- app/services/api_course_search_service.rb | 2 +- app/services/course_search_service.rb | 16 +++++----- .../courses/assign_tda_attributes_service.rb | 4 +-- app/views/find/courses/_advice.html.erb | 2 +- .../courses/editing_course_outcome_spec.rb | 32 +++++++++---------- ...db_backed_funding_feature_inactive_spec.rb | 22 ++++++------- spec/models/course_spec.rb | 24 +++++++------- spec/services/course_search_service_spec.rb | 2 +- .../assign_tda_attributes_service_spec.rb | 2 +- ...db_backed_funding_feature_disabled_spec.rb | 2 +- 13 files changed, 62 insertions(+), 62 deletions(-) diff --git a/app/controllers/find/search/visa_status_controller.rb b/app/controllers/find/search/visa_status_controller.rb index a258208044..9f24408ae8 100644 --- a/app/controllers/find/search/visa_status_controller.rb +++ b/app/controllers/find/search/visa_status_controller.rb @@ -26,7 +26,7 @@ def create private def next_step_path - if course_type_answer_determiner.show_exit_page? + if degree_type_answer_determiner.show_exit_page? find_no_degree_and_requires_visa_sponsorship_path(filter_params[:find_visa_status_form]) else find_results_path( @@ -40,8 +40,8 @@ def next_step_path end end - def course_type_answer_determiner - @course_type_answer_determiner ||= CourseTypeAnswerDeterminer.new( + def degree_type_answer_determiner + @degree_type_answer_determiner ||= CourseTypeAnswerDeterminer.new( university_degree_status: form_params[:university_degree_status], age_group: form_params[:age_group], visa_status: form_params[:visa_status] diff --git a/app/controllers/publish/courses/outcome_controller.rb b/app/controllers/publish/courses/outcome_controller.rb index 10a3343383..cf192f2d4e 100644 --- a/app/controllers/publish/courses/outcome_controller.rb +++ b/app/controllers/publish/courses/outcome_controller.rb @@ -63,7 +63,7 @@ def handle_qualification_update if undergraduate_to_other_qualification? @course.enrichments.find_or_initialize_draft.update(course_length: nil, salary_details: nil) @course.update( - course_type: 'postgraduate', + degree_type: 'postgraduate', a_level_subject_requirements: [], accept_pending_a_level: nil, accept_a_level_equivalency: nil, diff --git a/app/models/course.rb b/app/models/course.rb index 352c0010f8..44409fae5a 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -49,10 +49,10 @@ class Course < ApplicationRecord open: 1 }, prefix: :application_status - enum :course_type, { + enum :degree_type, { postgraduate: 'postgraduate', undergraduate: 'undergraduate' - }, suffix: :course_type + }, suffix: :degree_type enum :funding, { not_set: 'not_set', @@ -332,8 +332,8 @@ def new_draft_attributes ) } - scope :with_course_type, lambda { |course_type| - if course_type == :undergraduate + scope :with_degree_type, lambda { |degree_type| + if degree_type == :undergraduate where(program_type: Course.program_types[:teacher_degree_apprenticeship]) else where.not(program_type: Course.program_types[:teacher_degree_apprenticeship]) diff --git a/app/services/api_course_search_service.rb b/app/services/api_course_search_service.rb index d2e7032326..eafaa4b9d5 100644 --- a/app/services/api_course_search_service.rb +++ b/app/services/api_course_search_service.rb @@ -5,7 +5,7 @@ def course_order(outer_scope) outer_scope.order('course.created_at': :asc) end - def filter_by_course_type(scope) + def filter_by_degree_type(scope) scope # we want to return all course types in the API end end diff --git a/app/services/course_search_service.rb b/app/services/course_search_service.rb index e205530bed..f90025cd35 100644 --- a/app/services/course_search_service.rb +++ b/app/services/course_search_service.rb @@ -7,12 +7,12 @@ def initialize( filter:, sort: nil, course_scope: Course, - course_type_answer_determiner: Find::CourseTypeAnswerDeterminer + degree_type_answer_determiner: Find::CourseTypeAnswerDeterminer ) @filter = filter || {} @course_scope = course_scope @sort = sort - @course_type_answer_determiner = course_type_answer_determiner.new( + @degree_type_answer_determiner = degree_type_answer_determiner.new( university_degree_status: @filter['university_degree_status'], age_group: @filter['age_group'], visa_status: @filter['visa_status'] @@ -21,7 +21,7 @@ def initialize( def call scope = course_scope - scope = filter_by_course_type(scope) + scope = filter_by_degree_type(scope) scope = scope.with_salary if funding_filter_salary? scope = scope.with_qualifications(qualifications) if qualifications.any? scope = scope.application_status_open if applications_open? @@ -91,12 +91,12 @@ def course_order(outer_scope) outer_scope end - def filter_by_course_type(scope) - scope.with_course_type(course_type) + def filter_by_degree_type(scope) + scope.with_degree_type(degree_type) end - def course_type - return :undergraduate if @course_type_answer_determiner.show_undergraduate_courses? + def degree_type + return :undergraduate if @degree_type_answer_determiner.show_undergraduate_courses? :postgraduate end @@ -222,7 +222,7 @@ def funding_filter_salary? end def qualifications - return [] if filter[:qualification].blank? || course_type == :undergraduate + return [] if filter[:qualification].blank? || degree_type == :undergraduate filter[:qualification] = filter[:qualification].values if filter[:qualification].is_a?(Hash) filter[:qualification] = filter[:qualification].split(',') if filter[:qualification].is_a?(String) diff --git a/app/services/publish/courses/assign_tda_attributes_service.rb b/app/services/publish/courses/assign_tda_attributes_service.rb index 0249c31cde..0aae74981a 100644 --- a/app/services/publish/courses/assign_tda_attributes_service.rb +++ b/app/services/publish/courses/assign_tda_attributes_service.rb @@ -10,7 +10,7 @@ def initialize(course) def call if FeatureService.enabled?(:db_backed_funding_type) @course.assign_attributes( - course_type: 'undergraduate', + degree_type: 'undergraduate', funding: 'apprenticeship', study_mode: 'full_time', program_type: 'teacher_degree_apprenticeship', @@ -22,7 +22,7 @@ def call ) else @course.assign_attributes( - course_type: 'undergraduate', + degree_type: 'undergraduate', funding_type: 'apprenticeship', study_mode: 'full_time', program_type: 'teacher_degree_apprenticeship', diff --git a/app/views/find/courses/_advice.html.erb b/app/views/find/courses/_advice.html.erb index dd40c42438..fe06eda118 100644 --- a/app/views/find/courses/_advice.html.erb +++ b/app/views/find/courses/_advice.html.erb @@ -1,7 +1,7 @@

<%= t(".heading") %>

- <% if course.postgraduate_course_type? %> + <% if course.postgraduate_degree_type? %> <%= t( ".postgraduate.body_html", teacher_training_adviser_link: govuk_link_to( diff --git a/spec/features/publish/courses/editing_course_outcome_spec.rb b/spec/features/publish/courses/editing_course_outcome_spec.rb index 9cfd41b57b..816d57407d 100644 --- a/spec/features/publish/courses/editing_course_outcome_spec.rb +++ b/spec/features/publish/courses/editing_course_outcome_spec.rb @@ -40,7 +40,7 @@ and_there_is_a_qts_course_i_want_to_edit when_i_visit_the_course_outcome_page_in_the_next_cycle and_i_choose_undergraduate_degree_with_qts - and_the_course_type_is_postgraduate + and_the_degree_type_is_postgraduate and_i_submit then_the_default_options_for_a_tda_course_should_be_applied end @@ -52,9 +52,9 @@ and_the_db_backed_funding_type_feature_flag_is_enabled and_there_is_a_tda_course_i_want_to_edit when_i_visit_the_course_outcome_page_in_the_next_cycle - and_the_course_type_is_undergraduate + and_the_degree_type_is_undergraduate and_i_choose_qts - and_the_course_type_is_postgraduate + and_the_degree_type_is_postgraduate and_the_back_link_points_to_the_outcome_page and_i_choose_the_fee_paying and_the_back_link_points_to_the_funding_type_page @@ -82,9 +82,9 @@ and_the_db_backed_funding_type_feature_flag_is_enabled and_there_is_a_tda_course_i_want_to_edit when_i_visit_the_course_outcome_page_in_the_next_cycle - and_the_course_type_is_undergraduate + and_the_degree_type_is_undergraduate and_i_choose_qts - and_the_course_type_is_postgraduate + and_the_degree_type_is_postgraduate and_the_back_link_points_to_the_outcome_page and_i_choose_salaried and_the_back_link_points_to_the_funding_type_page @@ -104,7 +104,7 @@ and_there_is_a_qts_course_i_want_to_edit when_i_visit_the_course_outcome_page_in_the_next_cycle and_i_choose_undergraduate_degree_with_qts - and_the_course_type_is_postgraduate + and_the_degree_type_is_postgraduate and_i_submit then_the_default_options_for_a_tda_course_should_be_applied end @@ -116,9 +116,9 @@ and_the_db_backed_funding_type_feature_flag_is_disabled and_there_is_a_tda_course_i_want_to_edit when_i_visit_the_course_outcome_page_in_the_next_cycle - and_the_course_type_is_undergraduate + and_the_degree_type_is_undergraduate and_i_choose_qts - and_the_course_type_is_postgraduate + and_the_degree_type_is_postgraduate and_the_back_link_points_to_the_outcome_page and_i_choose_the_fee_paying and_the_back_link_points_to_the_funding_type_page @@ -146,9 +146,9 @@ and_the_db_backed_funding_type_feature_flag_is_disabled and_there_is_a_tda_course_i_want_to_edit when_i_visit_the_course_outcome_page_in_the_next_cycle - and_the_course_type_is_undergraduate + and_the_degree_type_is_undergraduate and_i_choose_qts - and_the_course_type_is_postgraduate + and_the_degree_type_is_postgraduate and_the_back_link_points_to_the_outcome_page and_i_choose_salaried and_the_back_link_points_to_the_funding_type_page @@ -178,7 +178,7 @@ def and_there_is_a_qts_course_i_want_to_edit end def and_there_is_a_tda_course_i_want_to_edit - given_a_course_exists(:undergraduate_degree_with_qts, course_type: 'undergraduate') + given_a_course_exists(:undergraduate_degree_with_qts, degree_type: 'undergraduate') end def course_enrichment @@ -285,17 +285,17 @@ def when_i_visit_the_course_outcome_page_in_the_next_cycle ) end - def and_the_course_type_is_undergraduate - expect(course.undergraduate_course_type?).to be(true) + def and_the_degree_type_is_undergraduate + expect(course.undergraduate_degree_type?).to be(true) end - def and_the_course_type_is_postgraduate - expect(course.reload.postgraduate_course_type?).to be(true) + def and_the_degree_type_is_postgraduate + expect(course.reload.postgraduate_degree_type?).to be(true) end def then_the_default_options_for_a_tda_course_should_be_applied course.reload - expect(course.undergraduate_course_type?).to be(true) + expect(course.undergraduate_degree_type?).to be(true) expect(course.full_time?).to be(true) expect(course.funding_type == 'apprenticeship').to be(true) expect(course.can_sponsor_skilled_worker_visa).to be false diff --git a/spec/features/publish/courses/editing_course_outcome_with_db_backed_funding_feature_inactive_spec.rb b/spec/features/publish/courses/editing_course_outcome_with_db_backed_funding_feature_inactive_spec.rb index ed29d01ac6..284d3b2c79 100644 --- a/spec/features/publish/courses/editing_course_outcome_with_db_backed_funding_feature_inactive_spec.rb +++ b/spec/features/publish/courses/editing_course_outcome_with_db_backed_funding_feature_inactive_spec.rb @@ -43,7 +43,7 @@ and_there_is_a_qts_course_i_want_to_edit when_i_visit_the_course_outcome_page_in_the_next_cycle and_i_choose_undergraduate_degree_with_qts - and_the_course_type_is_postgraduate + and_the_degree_type_is_postgraduate and_i_submit then_the_default_options_for_a_tda_course_should_be_applied end @@ -55,9 +55,9 @@ and_the_db_backed_funding_type_feature_flag_is_disabled and_there_is_a_tda_course_i_want_to_edit when_i_visit_the_course_outcome_page_in_the_next_cycle - and_the_course_type_is_undergraduate + and_the_degree_type_is_undergraduate and_i_choose_qts - and_the_course_type_is_postgraduate + and_the_degree_type_is_postgraduate and_the_back_link_points_to_the_outcome_page and_i_choose_the_fee_paying and_the_back_link_points_to_the_funding_type_page @@ -85,9 +85,9 @@ and_the_db_backed_funding_type_feature_flag_is_disabled and_there_is_a_tda_course_i_want_to_edit when_i_visit_the_course_outcome_page_in_the_next_cycle - and_the_course_type_is_undergraduate + and_the_degree_type_is_undergraduate and_i_choose_qts - and_the_course_type_is_postgraduate + and_the_degree_type_is_postgraduate and_the_back_link_points_to_the_outcome_page and_i_choose_salaried and_the_back_link_points_to_the_funding_type_page @@ -117,7 +117,7 @@ def and_there_is_a_qts_course_i_want_to_edit end def and_there_is_a_tda_course_i_want_to_edit - given_a_course_exists(:undergraduate_degree_with_qts, course_type: 'undergraduate') + given_a_course_exists(:undergraduate_degree_with_qts, degree_type: 'undergraduate') end def course_enrichment @@ -224,17 +224,17 @@ def when_i_visit_the_course_outcome_page_in_the_next_cycle ) end - def and_the_course_type_is_undergraduate - expect(course.undergraduate_course_type?).to be(true) + def and_the_degree_type_is_undergraduate + expect(course.undergraduate_degree_type?).to be(true) end - def and_the_course_type_is_postgraduate - expect(course.reload.postgraduate_course_type?).to be(true) + def and_the_degree_type_is_postgraduate + expect(course.reload.postgraduate_degree_type?).to be(true) end def then_the_default_options_for_a_tda_course_should_be_applied course.reload - expect(course.undergraduate_course_type?).to be(true) + expect(course.undergraduate_degree_type?).to be(true) expect(course.full_time?).to be(true) expect(course.funding_type == 'apprenticeship').to be(true) expect(course.can_sponsor_skilled_worker_visa).to be false diff --git a/spec/models/course_spec.rb b/spec/models/course_spec.rb index ba0efe73d9..28062dea11 100644 --- a/spec/models/course_spec.rb +++ b/spec/models/course_spec.rb @@ -2901,47 +2901,47 @@ end end - describe 'course_type enum' do + describe 'degree_type enum' do subject(:course) { create(:course) } context 'default' do it 'sets the value as postgraduate' do - expect(course.course_type).to eq('postgraduate') + expect(course.degree_type).to eq('postgraduate') end end context 'undergraduate course' do it 'sets the value to undergraduate' do - course.undergraduate_course_type! - expect(course.reload.course_type).to eq('undergraduate') + course.undergraduate_degree_type! + expect(course.reload.degree_type).to eq('undergraduate') end end context 'postgraduate course' do it 'sets the value to postgraduate' do - course.postgraduate_course_type! - expect(course.reload.course_type).to eq('postgraduate') + course.postgraduate_degree_type! + expect(course.reload.degree_type).to eq('postgraduate') end end context 'validation' do - it 'raises an error when setting an invalid course_type' do - expect { course.update!(course_type: 'invalid') }.to raise_error(ArgumentError) + it 'raises an error when setting an invalid degree_type' do + expect { course.update!(degree_type: 'invalid') }.to raise_error(ArgumentError) end end context 'predicate methods' do it 'returns true for postgraduate?' do - expect(course.postgraduate_course_type?).to be true + expect(course.postgraduate_degree_type?).to be true end it 'returns false for undergraduate?' do - expect(course.undergraduate_course_type?).to be false + expect(course.undergraduate_degree_type?).to be false end it 'returns true for undergraduate? after setting to undergraduate' do - course.undergraduate_course_type! - expect(course.undergraduate_course_type?).to be true + course.undergraduate_degree_type! + expect(course.undergraduate_degree_type?).to be true end end end diff --git a/spec/services/course_search_service_spec.rb b/spec/services/course_search_service_spec.rb index b85502ce39..ecc4f879f9 100644 --- a/spec/services/course_search_service_spec.rb +++ b/spec/services/course_search_service_spec.rb @@ -32,7 +32,7 @@ ).and_return(course_with_includes) allow(course_with_includes).to receive(:where).and_return(outer_query_scope) - allow(scope).to receive(:with_course_type).and_return(scope) + allow(scope).to receive(:with_degree_type).and_return(scope) end describe 'when no scope is passed' do diff --git a/spec/services/publish/courses/assign_tda_attributes_service_spec.rb b/spec/services/publish/courses/assign_tda_attributes_service_spec.rb index 12db8ee15a..3df1e025ac 100644 --- a/spec/services/publish/courses/assign_tda_attributes_service_spec.rb +++ b/spec/services/publish/courses/assign_tda_attributes_service_spec.rb @@ -19,7 +19,7 @@ expect(course.additional_degree_subject_requirements).to be(false) expect(course.degree_subject_requirements).to be_nil expect(course.degree_grade).to eq('not_required') - expect(course.course_type).to eq('undergraduate') + expect(course.degree_type).to eq('undergraduate') end end end diff --git a/spec/services/publish/courses/assign_tda_attributes_service_with_db_backed_funding_feature_disabled_spec.rb b/spec/services/publish/courses/assign_tda_attributes_service_with_db_backed_funding_feature_disabled_spec.rb index 6a7b81a3bc..7b424e4732 100644 --- a/spec/services/publish/courses/assign_tda_attributes_service_with_db_backed_funding_feature_disabled_spec.rb +++ b/spec/services/publish/courses/assign_tda_attributes_service_with_db_backed_funding_feature_disabled_spec.rb @@ -22,7 +22,7 @@ expect(course.additional_degree_subject_requirements).to be(false) expect(course.degree_subject_requirements).to be_nil expect(course.degree_grade).to eq('not_required') - expect(course.course_type).to eq('undergraduate') + expect(course.degree_type).to eq('undergraduate') end end end From 037cb73608fba77c41e3526f31156f65fff7b103 Mon Sep 17 00:00:00 2001 From: Avin Hurry Date: Wed, 11 Sep 2024 13:48:02 +0100 Subject: [PATCH 2/2] [2280] Rename course_type_determiner To degree_type_determiner --- app/controllers/find/search/visa_status_controller.rb | 2 +- app/services/course_search_service.rb | 2 +- ...pe_answer_determiner.rb => degree_type_answer_determiner.rb} | 2 +- app/view_objects/find/result_filters/filters_view.rb | 2 +- ...determiner_spec.rb => degree_type_answer_determiner_spec.rb} | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) rename app/services/find/{course_type_answer_determiner.rb => degree_type_answer_determiner.rb} (97%) rename spec/services/find/{course_type_answer_determiner_spec.rb => degree_type_answer_determiner_spec.rb} (98%) diff --git a/app/controllers/find/search/visa_status_controller.rb b/app/controllers/find/search/visa_status_controller.rb index 9f24408ae8..5f6f53c90d 100644 --- a/app/controllers/find/search/visa_status_controller.rb +++ b/app/controllers/find/search/visa_status_controller.rb @@ -41,7 +41,7 @@ def next_step_path end def degree_type_answer_determiner - @degree_type_answer_determiner ||= CourseTypeAnswerDeterminer.new( + @degree_type_answer_determiner ||= DegreeTypeAnswerDeterminer.new( university_degree_status: form_params[:university_degree_status], age_group: form_params[:age_group], visa_status: form_params[:visa_status] diff --git a/app/services/course_search_service.rb b/app/services/course_search_service.rb index f90025cd35..1816eaa66a 100644 --- a/app/services/course_search_service.rb +++ b/app/services/course_search_service.rb @@ -7,7 +7,7 @@ def initialize( filter:, sort: nil, course_scope: Course, - degree_type_answer_determiner: Find::CourseTypeAnswerDeterminer + degree_type_answer_determiner: Find::DegreeTypeAnswerDeterminer ) @filter = filter || {} @course_scope = course_scope diff --git a/app/services/find/course_type_answer_determiner.rb b/app/services/find/degree_type_answer_determiner.rb similarity index 97% rename from app/services/find/course_type_answer_determiner.rb rename to app/services/find/degree_type_answer_determiner.rb index d22379c2c3..def201ce5c 100644 --- a/app/services/find/course_type_answer_determiner.rb +++ b/app/services/find/degree_type_answer_determiner.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Find - class CourseTypeAnswerDeterminer + class DegreeTypeAnswerDeterminer attr_reader :age_group, :visa_status, :university_degree_status def initialize(age_group:, visa_status:, university_degree_status:) diff --git a/app/view_objects/find/result_filters/filters_view.rb b/app/view_objects/find/result_filters/filters_view.rb index 057fe89ed4..182bd020f7 100644 --- a/app/view_objects/find/result_filters/filters_view.rb +++ b/app/view_objects/find/result_filters/filters_view.rb @@ -40,7 +40,7 @@ def qualification_params_nil? end def show_undergraduate_courses? - CourseTypeAnswerDeterminer.new( + DegreeTypeAnswerDeterminer.new( age_group: params[:age_group], university_degree_status: params[:university_degree_status], visa_status: params[:visa_status] diff --git a/spec/services/find/course_type_answer_determiner_spec.rb b/spec/services/find/degree_type_answer_determiner_spec.rb similarity index 98% rename from spec/services/find/course_type_answer_determiner_spec.rb rename to spec/services/find/degree_type_answer_determiner_spec.rb index b4a71aef39..b41d96e624 100644 --- a/spec/services/find/course_type_answer_determiner_spec.rb +++ b/spec/services/find/degree_type_answer_determiner_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe Find::CourseTypeAnswerDeterminer do +RSpec.describe Find::DegreeTypeAnswerDeterminer do describe '#show_undergraduate_courses?' do context 'when the age group is not further education, no degree, and no visa sponsorship required' do let(:params) do