Skip to content

Commit

Permalink
Adds validation to the not_assured_reason
Browse files Browse the repository at this point in the history
When this was implemented it undercover was failing and blocking the pipeline, now that it has been reverted we can re-add this validation.
  • Loading branch information
Kizr committed Dec 19, 2024
1 parent ab40b4d commit 1fb529e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/claims/mentor_training.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down
19 changes: 19 additions & 0 deletions spec/models/claims/mentor_training_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down

0 comments on commit 1fb529e

Please sign in to comment.