From 1fb529e8589533aed45c3e642b667b80a43b7c27 Mon Sep 17 00:00:00 2001 From: Ben Abraham <16797406+Kizr@users.noreply.github.com> Date: Wed, 18 Dec 2024 14:06:59 +0000 Subject: [PATCH] Adds validation to the `not_assured_reason` When this was implemented it undercover was failing and blocking the pipeline, now that it has been reverted we can re-add this validation. --- app/models/claims/mentor_training.rb | 2 +- spec/models/claims/mentor_training_spec.rb | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/models/claims/mentor_training.rb b/app/models/claims/mentor_training.rb index 62f4714b8..b17c67feb 100644 --- a/app/models/claims/mentor_training.rb +++ b/app/models/claims/mentor_training.rb @@ -58,7 +58,7 @@ class Claims::MentorTraining < ApplicationRecord } validates :reason_rejected, presence: true, if: -> { rejected } validates :hours_rejected, presence: true, if: -> { rejected } - # validates :reason_not_assured, presence: true, if: -> { not_assured } TODO: Undercover is failing for some reason even when tested. + validates :reason_not_assured, presence: true, if: -> { not_assured } scope :without_hours, -> { where(hours_completed: nil).order_by_mentor_full_name } scope :order_by_mentor_full_name, -> { joins(:mentor).merge(Mentor.order_by_full_name) } diff --git a/spec/models/claims/mentor_training_spec.rb b/spec/models/claims/mentor_training_spec.rb index edaff41ff..352bf16d5 100644 --- a/spec/models/claims/mentor_training_spec.rb +++ b/spec/models/claims/mentor_training_spec.rb @@ -43,6 +43,25 @@ end describe "validations" do + describe "reason_not_assured" do + context "when not_assured is true" do + let(:mentor_training) { build(:mentor_training, not_assured: true) } + + it "validates that the reason not assured is present" do + expect(mentor_training.valid?).to be(false) + expect(mentor_training.errors["reason_not_assured"]).to include("can't be blank") + end + end + + context "when not_assured is false" do + let(:mentor_training) { build(:mentor_training, not_assured: false) } + + it "confirms the mentor training is valid" do + expect(mentor_training.valid?).to be(true) + end + end + end + describe "rejected" do context "when rejected is true" do let(:mentor_training) { build(:mentor_training, rejected: true) }