Skip to content

Commit

Permalink
Use reviwbyuser rather then submittedbyuser for vacancyrejected email
Browse files Browse the repository at this point in the history
  • Loading branch information
cofaulco committed Jun 8, 2021
1 parent 310921d commit e05e517
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public async Task GivenVacancyRejectedEvent_ProviderResolver_ShouldBeSet()
await _sut.HandleAsync(@event);

//Assert
_sentCommRequest.ParticipantsResolverName.Should().Be(CommunicationConstants.ParticipantResolverNames.ProviderParticipantsResolverName);
_sentCommRequest.ParticipantsResolverName.Should().Be(CommunicationConstants.ParticipantResolverNames.VacancyParticipantsResolverName);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private CommunicationRequest GetRejectedVacancyCommunicationRequest(long vacancy
{
var communicationRequest = new CommunicationRequest(
CommunicationConstants.RequestType.VacancyRejectedByEmployer,
CommunicationConstants.ParticipantResolverNames.ProviderParticipantsResolverName,
CommunicationConstants.ParticipantResolverNames.VacancyParticipantsResolverName,
CommunicationConstants.ServiceName);
communicationRequest.AddEntity(CommunicationConstants.EntityTypes.Vacancy, vacancyReference);
communicationRequest.AddEntity(CommunicationConstants.EntityTypes.ApprenticeshipServiceUrl, vacancyReference);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public async Task<IEnumerable<CommunicationUser>> GetParticipantsAsync(Communica
{
users = await _userRepository.GetProviderUsersAsync(vacancy.TrainingProvider.Ukprn.GetValueOrDefault());
}
return ParticipantResolverPluginHelper.ConvertToCommunicationUsers(users, vacancy.SubmittedByUser.UserId);

return ParticipantResolverPluginHelper.ConvertToCommunicationUsers(users, vacancy.SubmittedByUser?.UserId ?? vacancy.ReviewByUser?.UserId);
}

public async Task<IEnumerable<CommunicationMessage>> ValidateParticipantAsync(IEnumerable<CommunicationMessage> messages)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,31 @@ public async Task ShouldReturnVacancyOwnerAsPrimaryUser()
participants.Single(p => p.UserId != PrimaryUserId).Participation.Should().Be(UserParticipation.SecondaryUser);
}

[Fact]
public async Task ShouldProviderReviewSenderAsPrimaryUser()
{
var user = _fixture.Build<VacancyUser>().With(v => v.UserId, PrimaryUserId).Create();
var vacancy = _fixture
.Build<Vacancy>()
.With(v => v.OwnerType, OwnerType.Provider)
.Without(v => v.SubmittedByUser)
.With(v => v.ReviewByUser, user)
.Create();

_mockVacancyRepository.Setup(v => v.GetVacancyAsync(It.IsAny<long>())).ReturnsAsync(vacancy);

var sut = GetSut();

var request = new CommunicationRequest(_fixture.Create<string>(), _fixture.Create<string>(), _fixture.Create<string>());
request.AddEntity(CommunicationConstants.EntityTypes.Vacancy, _fixture.Create<long>());

var participants = await sut.GetParticipantsAsync(request);

participants.Count().Should().Be(2);
participants.Single(p => p.UserId == PrimaryUserId).Participation.Should().Be(UserParticipation.PrimaryUser);
participants.Single(p => p.UserId != PrimaryUserId).Participation.Should().Be(UserParticipation.SecondaryUser);
}

private VacancyParticipantsResolverPlugin GetSut()
{
return new VacancyParticipantsResolverPlugin(
Expand Down

0 comments on commit e05e517

Please sign in to comment.