diff --git a/app/controllers/appropriate_bodies/teachers/release_ect_controller.rb b/app/controllers/appropriate_bodies/teachers/release_ect_controller.rb index ba5a5f96..6f58a00c 100644 --- a/app/controllers/appropriate_bodies/teachers/release_ect_controller.rb +++ b/app/controllers/appropriate_bodies/teachers/release_ect_controller.rb @@ -17,7 +17,7 @@ def create release_ect = AppropriateBodies::ReleaseECT.new(appropriate_body: @appropriate_body, pending_induction_submission: @pending_induction_submission) PendingInductionSubmission.transaction do - if @pending_induction_submission.save(context: :record_period) && release_ect.release! + if @pending_induction_submission.save(context: :release_ect) && release_ect.release! redirect_to ab_teacher_release_ect_path(@teacher) else render :new diff --git a/app/models/pending_induction_submission.rb b/app/models/pending_induction_submission.rb index 2c0cc413..b6e7b821 100644 --- a/app/models/pending_induction_submission.rb +++ b/app/models/pending_induction_submission.rb @@ -37,12 +37,12 @@ class PendingInductionSubmission < ApplicationRecord validates :finished_on, presence: { message: "Enter a finish date" }, - on: :record_period + on: %i[release_ect record_outcome] validates :number_of_terms, inclusion: { in: 0..16, message: "Terms must be between 0 and 16" }, - on: :record_period + on: %i[release_ect record_outcome] validates :date_of_birth, presence: { message: "Enter a date of birth" }, diff --git a/spec/models/pending_induction_submission_spec.rb b/spec/models/pending_induction_submission_spec.rb index 59d9c460..8f34d4c1 100644 --- a/spec/models/pending_induction_submission_spec.rb +++ b/spec/models/pending_induction_submission_spec.rb @@ -48,8 +48,16 @@ it { is_expected.to validate_inclusion_of(:induction_programme).in_array(%w[fip cip diy]).with_message("Choose an induction programme").on(:register_ect) } end + describe "started_on" do + it { is_expected.to validate_presence_of(:started_on).with_message("Enter a start date").on(:register_ect) } + end + + describe "finished_on" do + it { is_expected.to validate_presence_of(:finished_on).with_message("Enter a finish date").on(%i[release_ect record_outcome]) } + end + describe "number_of_terms" do - it { is_expected.to validate_inclusion_of(:number_of_terms).in_range(0..16).with_message("Terms must be between 0 and 16").on(:record_period) } + it { is_expected.to validate_inclusion_of(:number_of_terms).in_range(0..16).with_message("Terms must be between 0 and 16").on(%i[release_ect record_outcome]) } end describe "confirmed" do