Skip to content

Commit

Permalink
CST.2800: do not move from frozen cohort participants with ESP or IST…
Browse files Browse the repository at this point in the history
…IP appropriate body
  • Loading branch information
ltello committed Nov 11, 2024
1 parent d8f0e56 commit c261e38
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 5 deletions.
11 changes: 11 additions & 0 deletions app/models/appropriate_body.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
class AppropriateBody < ApplicationRecord
has_paper_trail

ESP = "Educational Success Partners (ESP)"
ISTIP = "Independent Schools Teacher Induction Panel (IStip)"

enum body_type: {
local_authority: "local_authority",
teaching_school_hub: "teaching_school_hub",
Expand Down Expand Up @@ -31,6 +34,14 @@ def self.ransackable_attributes(_auth_object = nil)
%w[name]
end

def self.esp
find_by_name(ESP)
end

def self.istip
find_by_name(ISTIP)
end

private

def update_analytics
Expand Down
6 changes: 5 additions & 1 deletion app/services/participants/check_and_set_completion_date.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ def continue_training
end

def continue_training?
in_progress_induction_status? && participant_profile.unfinished?
in_progress_induction_status? && participant_profile.unfinished? && !esp_or_istip?
end

def esp_or_istip?
[AppropriateBody.esp, AppropriateBody.istip].compact.include?(participant_profile.latest_induction_record.appropriate_body)
end

def induction
Expand Down
10 changes: 10 additions & 0 deletions spec/factories/appropriate_bodies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
body_type { "national" }
end

trait :esp do
name { AppropriateBody::ESP }
body_type { "national" }
end

trait :istip do
name { AppropriateBody::ISTIP }
body_type { "national" }
end

trait :supports_independent_schools_only do
listed_for_school_type_codes { GiasTypes::INDEPENDENT_SCHOOLS_TYPE_CODES }
end
Expand Down
33 changes: 29 additions & 4 deletions spec/services/participants/check_and_set_completion_date_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,35 @@
let(:induction_status) { "InProgress" }
let(:completion_date) {}

it "sit the participant in the active registration cohort" do
expect { service_call }.to change { participant_profile.schedule.cohort }
.from(cohort)
.to(Cohort.active_registration_cohort)
let!(:esp) { create(:appropriate_body, :esp) }
let!(:istip) { create(:appropriate_body, :istip) }

context "when the participant is has not ESP or ISTIP appropriate body" do
it "sit the participant in the active registration cohort" do
expect { service_call }.to change { participant_profile.schedule.cohort }
.from(cohort)
.to(Cohort.active_registration_cohort)
end
end

context "when the participant has ESP as appropriate body" do
before do
participant_profile.latest_induction_record.update!(appropriate_body: esp)
end

it "do not sit the participant in the active registration cohort" do
expect { service_call }.not_to change { participant_profile.schedule.cohort }
end
end

context "when the participant has ISTIP as appropriate body" do
before do
participant_profile.latest_induction_record.update!(appropriate_body: istip)
end

it "do not sit the participant in the active registration cohort" do
expect { service_call }.not_to change { participant_profile.schedule.cohort }
end
end
end
end
Expand Down

0 comments on commit c261e38

Please sign in to comment.