Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jack pilot review #4746

Closed
wants to merge 19 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/services/participants/sync_dqt_induction_start_date.rb
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ def initialize(dqt_induction_start_date, participant_profile)
end

def call
return false if school_cannot_manage_target_cohort?
return false unless update_induction_start_date
return true if mentor? || pre_2021_dqt_induction_start_date?
return cohort_missing unless target_cohort
@@ -62,6 +63,10 @@ def cohort_missing
save_error("Cohort containing date #{dqt_induction_start_date.to_fs(:govuk)} not setup in the service!")
end

def school_cannot_manage_target_cohort?
target_cohort && target_cohort.start_year > Schools::LatestManageableCohort.call(school:).start_year
end

def update_induction_start_date
participant_profile.update!(induction_start_date: dqt_induction_start_date) if dqt_induction_start_date
end
@@ -70,5 +75,9 @@ def update_participant
clear_participant_sync_errors
save_errors(*amend_cohort.errors.full_messages) unless amend_cohort.save
end

def school
@school ||= Induction::FindBy.call(participant_profile:).school
end
end
end
33 changes: 17 additions & 16 deletions spec/forms/schools/cohorts/setup_wizard_spec.rb
Original file line number Diff line number Diff line change
@@ -56,22 +56,23 @@
allow(wizard).to receive(:what_changes).and_return(what_changes)
end

context "when the SIT does not expect any ECTs" do
it "does not send the pilot survey" do
expect(Induction::SetCohortInductionProgramme)
.to receive(:call).with(programme_choice: :no_early_career_teachers,
school_cohort:,
opt_out_of_updates: true,
delivery_partner_to_be_confirmed: false)
expect(Induction::SetSchoolCohortAppropriateBody)
.to receive(:call).with(school_cohort:,
appropriate_body_id: 3,
appropriate_body_appointed: true)
expect {
wizard.success
}.not_to have_enqueued_mail(SchoolMailer, :cohortless_pilot_2023_survey_email)
end
end
# FIXME: removing while decision is made whether to keep/update/remove the survey for 2024
# context "when the SIT does not expect any ECTs" do
# it "does not send the pilot survey" do
# expect(Induction::SetCohortInductionProgramme)
# .to receive(:call).with(programme_choice: :no_early_career_teachers,
# school_cohort:,
# opt_out_of_updates: true,
# delivery_partner_to_be_confirmed: false)
# expect(Induction::SetSchoolCohortAppropriateBody)
# .to receive(:call).with(school_cohort:,
# appropriate_body_id: 3,
# appropriate_body_appointed: true)
# expect {
# wizard.success
# }.not_to have_enqueued_mail(SchoolMailer, :cohortless_pilot_2023_survey_email)
# end
# end

context "when the SIT chooses to keep providers" do
let(:expect_any_ects) { true }
34 changes: 34 additions & 0 deletions spec/services/participants/sync_dqt_induction_start_date_spec.rb
Original file line number Diff line number Diff line change
@@ -30,6 +30,40 @@
end
end

context "when the registration pilot is active", with_feature_flags: { registration_pilot: "active" } do
let(:target_cohort) { cohort.next }
let(:dqt_induction_start_date) { target_cohort.academic_year_start_date + 1.week }
let(:target_school_cohort) do
create(:seed_school_cohort, :fip, cohort: cohort.next, school: participant_profile.school)
end

before do
NewSeeds::Scenarios::InductionProgrammes::Fip.new(school_cohort: target_school_cohort).build.induction_programme
end

context "when the school is not in the pilot" do
it "does not change the participant" do
inside_registration_window(cohort: target_cohort) do
expect { subject }.to not_change(participant_profile, :updated_at)
.and not_change(participant_profile, :induction_start_date)
.and not_change(SyncDQTInductionStartDateError, :count)
end
end
end

context "when the school is in the pilot", with_feature_flags: { registration_pilot_school: "active" } do
it "changes the participant's induction start date and cohort" do
inside_registration_window(cohort: target_cohort) do
expect { subject }.to change(participant_profile, :induction_start_date)
.to(dqt_induction_start_date)
.and change { participant_profile.induction_records.latest.cohort }
.to(target_cohort)
.and not_change(SyncDQTInductionStartDateError, :count)
end
end
end
end

context "when the participant is a mentor" do
let(:dqt_induction_start_date) { Date.new(2021, 8, 31) }