From c40d41617d5084d0479b1b31e741e0d6cd1ca9cf Mon Sep 17 00:00:00 2001 From: Martyn Whitwell Date: Tue, 7 Jan 2025 11:35:53 +0000 Subject: [PATCH] test fixes --- .../Models/Crm/Validators/CandidateValidator.cs | 9 +++++---- GetIntoTeachingApiTests/Jobs/UpsertCandidateJobTests.cs | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/GetIntoTeachingApi/Models/Crm/Validators/CandidateValidator.cs b/GetIntoTeachingApi/Models/Crm/Validators/CandidateValidator.cs index 96b0de480..8f2e3b7fd 100644 --- a/GetIntoTeachingApi/Models/Crm/Validators/CandidateValidator.cs +++ b/GetIntoTeachingApi/Models/Crm/Validators/CandidateValidator.cs @@ -57,10 +57,11 @@ public CandidateValidator(IStore store, IDateTimeProvider dateTime) RuleFor(candidate => candidate.InitialTeacherTrainingYearId) .SetValidator(new PickListItemIdValidator("contact", "dfe_ittyear", store)) .Unless(candidate => candidate.InitialTeacherTrainingYearId == null); - // RuleFor(candidate => candidate.ChannelId) - // .NotNull() - // .When(candidate => candidate.Id == null) - // .SetValidator(new PickListItemIdValidator("contact", "dfe_channelcreation", store)); + RuleFor(candidate => candidate.ChannelId) + .NotNull() + .When(candidate => candidate.Id == null) + .When(candidate => !candidate.ContactChannelCreations.Any()) + .SetValidator(new PickListItemIdValidator("contact", "dfe_channelcreation", store)); RuleFor(candidate => candidate.HasGcseEnglishId) .SetValidator(new PickListItemIdValidator("contact", "dfe_websitehasgcseenglish", store)) .Unless(candidate => candidate.HasGcseEnglishId == null); diff --git a/GetIntoTeachingApiTests/Jobs/UpsertCandidateJobTests.cs b/GetIntoTeachingApiTests/Jobs/UpsertCandidateJobTests.cs index 0dbbaaa63..d3c39ca7c 100644 --- a/GetIntoTeachingApiTests/Jobs/UpsertCandidateJobTests.cs +++ b/GetIntoTeachingApiTests/Jobs/UpsertCandidateJobTests.cs @@ -135,7 +135,7 @@ private static bool IsMatch(object objectA, object objectB) private static string Signature(Candidate candidate) { - var changedProperties = "MergedIsNewRegistrantTeachingEventRegistrationsQualificationsPastTeachingPositionsApplicationFormsSchoolExperiencesIdEmail"; + var changedProperties = "MergedIsNewRegistrantTeachingEventRegistrationsQualificationsPastTeachingPositionsApplicationFormsSchoolExperiencesContactChannelCreationsIdEmail"; return $"{candidate.Id}-{candidate.Email}-{changedProperties}"; } }