From c261e38fc4379235ac4dc3de1ac7df1aa8d39daf Mon Sep 17 00:00:00 2001 From: Lorenzo Tello Date: Fri, 8 Nov 2024 17:31:07 +0000 Subject: [PATCH] CST.2800: do not move from frozen cohort participants with ESP or ISTIP appropriate body --- app/models/appropriate_body.rb | 11 +++++++ .../check_and_set_completion_date.rb | 6 +++- spec/factories/appropriate_bodies.rb | 10 ++++++ .../check_and_set_completion_date_spec.rb | 33 ++++++++++++++++--- 4 files changed, 55 insertions(+), 5 deletions(-) diff --git a/app/models/appropriate_body.rb b/app/models/appropriate_body.rb index abdf806b13..b3268a9fb4 100644 --- a/app/models/appropriate_body.rb +++ b/app/models/appropriate_body.rb @@ -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", @@ -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 diff --git a/app/services/participants/check_and_set_completion_date.rb b/app/services/participants/check_and_set_completion_date.rb index 19b5b3dc3d..99b06db299 100644 --- a/app/services/participants/check_and_set_completion_date.rb +++ b/app/services/participants/check_and_set_completion_date.rb @@ -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 diff --git a/spec/factories/appropriate_bodies.rb b/spec/factories/appropriate_bodies.rb index 0f593f6db7..569d61c921 100644 --- a/spec/factories/appropriate_bodies.rb +++ b/spec/factories/appropriate_bodies.rb @@ -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 diff --git a/spec/services/participants/check_and_set_completion_date_spec.rb b/spec/services/participants/check_and_set_completion_date_spec.rb index dcc2ac92c5..14da90db41 100644 --- a/spec/services/participants/check_and_set_completion_date_spec.rb +++ b/spec/services/participants/check_and_set_completion_date_spec.rb @@ -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