Skip to content

Commit

Permalink
[2267] Implement training route
Browse files Browse the repository at this point in the history
Add a way to calculate training routes based on funding and course type
  • Loading branch information
avinhurry committed Sep 5, 2024
1 parent 845d90e commit 4104eba
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/models/course.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ class Course < ApplicationRecord

A_LEVEL_ATTRIBUTES = %i[a_level_subject_requirements accept_pending_a_level accept_a_level_equivalency additional_a_level_equivalencies].freeze

TRAINING_ROUTE_MAP = {
%w[postgraduate fee] => 'fee_funded_initial_teacher_training',
%w[postgraduate salary] => 'school_direct_salaried',
%w[postgraduate apprenticeship] => 'postgraduate_teacher_apprenticeship',
%w[undergraduate salary] => 'teacher_degree_apprenticeship'
}.freeze

after_initialize :set_defaults

before_discard do
Expand Down Expand Up @@ -752,6 +759,10 @@ def funding_type=(funding_type)
Courses::AssignProgramTypeService.new.execute(funding_type, self)
end

def training_route
TRAINING_ROUTE_MAP.fetch([course_type, funding_type], 'unknown_training_route')
end

def ensure_site_statuses_match_study_mode
site_statuses.not_no_vacancies.each do |site_status|
update_vac_status(study_mode, site_status)
Expand Down
27 changes: 27 additions & 0 deletions spec/models/course_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3450,4 +3450,31 @@
end
end
end

describe '#training_route' do
it 'returns teacher_degree_apprenticeship for undergraduate and salaried' do
course = build(:course, funding: 'salary', course_type: 'undergraduate')
expect(course.training_route).to eq('teacher_degree_apprenticeship')
end

it 'returns school_direct_salaried for postgraduate and salaried' do
course = build(:course, funding: 'salary', course_type: 'postgraduate')
expect(course.training_route).to eq('school_direct_salaried')
end

it 'returns postgraduate_teaching_apprenticeship for postgraduate and apprenticeship' do
course = build(:course, funding: 'apprenticeship', course_type: 'postgraduate')
expect(course.training_route).to eq('postgraduate_teacher_apprenticeship')
end

it 'returns fee_funded_initial_teacher_training for postgraduate and fee' do
course = build(:course, funding: 'fee', course_type: 'postgraduate')
expect(course.training_route).to eq('fee_funded_initial_teacher_training')
end

it 'returns unknown_training_route for unknown course_type and funding_type combination' do
course = build(:course, funding: 'fee', course_type: 'undergraduate')
expect(course.training_route).to eq('unknown_training_route')
end
end
end

0 comments on commit 4104eba

Please sign in to comment.