Skip to content

Commit

Permalink
Fixed template fields so they match the names in the templates
Browse files Browse the repository at this point in the history
  • Loading branch information
Pauljgraham committed Feb 12, 2020
1 parent df9bdf9 commit 1e6f97e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public async Task Handle_WhenCalledAndCohortIsTransfer_ThenShouldBuildEmailReque
var fixture = new CohortAssignedToProviderEventHandlerTestsFixture().SetupTransferCohort();
await fixture.Handle();

fixture.VerfiyProviderTransferEmailRequestIsCreatedAndSentCorrectly();
fixture.VerfiyProviderTransferEmailRequestIsCreatedAndSentCorrectly(fixture.GetCohortSummaryQueryResult.LastAction);
}
}

Expand Down Expand Up @@ -94,14 +94,17 @@ public void VerfiyProviderEmailRequestIsCreatedAndSentCorrectly(LastAction lastA
p.Tokens["type"] == actionType), default));
}

public void VerfiyProviderTransferEmailRequestIsCreatedAndSentCorrectly()
public void VerfiyProviderTransferEmailRequestIsCreatedAndSentCorrectly(LastAction lastAction)
{
var actionType = lastAction == LastAction.Approve ? "approval" : "review";

PasAccountApiClient.Verify(x => x.SendEmailToAllProviderRecipients(GetCohortSummaryQueryResult.ProviderId.Value,
It.Is<ProviderEmailRequest>(p =>
p.TemplateId == "ProviderTransferCommitmentNotification" &&
p.ExplicitEmailAddresses[0] == GetCohortSummaryQueryResult.LastUpdatedByProviderEmail &&
p.Tokens["cohort_reference"] == GetCohortSummaryQueryResult.CohortReference &&
p.Tokens["receiving_employer"] == GetCohortSummaryQueryResult.LegalEntityName), default));
p.Tokens["employer_name"] == GetCohortSummaryQueryResult.LegalEntityName &&
p.Tokens["type"] == actionType), default));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ private ProviderEmailRequest BuildEmailRequest(GetCohortSummaryQueryResult cohor
}

request.Tokens.Add("cohort_reference", cohortSummary.CohortReference);
request.Tokens.Add("type", cohortSummary.LastAction == LastAction.Approve ? "approval" : "review");

if (cohortSummary.IsFundedByTransfer)
{
request.TemplateId = "ProviderTransferCommitmentNotification";
request.Tokens.Add("receiving_employer", cohortSummary.LegalEntityName);
request.Tokens.Add("employer_name", cohortSummary.LegalEntityName);
}
else
{
request.TemplateId = "ProviderCommitmentNotification";
request.Tokens.Add("type", cohortSummary.LastAction == LastAction.Approve ? "approval" : "review");
}

return request;
Expand Down

0 comments on commit 1e6f97e

Please sign in to comment.