Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DLSV2-598 Fixes get recipient query and data tests #1288

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace DigitalLearningSolutions.Data.Tests.Services
using DigitalLearningSolutions.Data.Services;
using DigitalLearningSolutions.Data.Tests.TestHelpers;
using FakeItEasy;
using FizzWare.NBuilder;
using FluentAssertions;
using FluentAssertions.Execution;
using Microsoft.Extensions.Configuration;
Expand Down Expand Up @@ -51,7 +52,7 @@ public void Setup()
centresDataService = A.Fake<ICentresDataService>();
config = A.Fake<IConfiguration>();
supervisorDelegateService = A.Fake<ISupervisorDelegateService>();
notificationDataService = A.Fake<NotificationDataService>();
notificationDataService = A.Fake<INotificationDataService>();
userDataService = A.Fake<IUserDataService>();

A.CallTo(() => config["CurrentSystemBaseUrl"]).Returns(OldSystemBaseUrl);
Expand Down Expand Up @@ -154,17 +155,11 @@ public void Registering_delegate_sends_approval_email_with_old_site_approval_lin
// Then
A.CallTo(
() =>
emailService.SendEmail(
A<Email>.That.Matches(
e =>
e.To[0] == ApproverEmail &&
e.Cc.IsNullOrEmpty() &&
e.Bcc.IsNullOrEmpty() &&
e.Subject == "Digital Learning Solutions Registration Requires Approval" &&
e.Body.TextBody.Contains(OldSystemBaseUrl + "/tracking/approvedelegates")
)
notificationDataService.GetAdminRecipientsForCentreNotification(
model.Centre,
4
)
).MustHaveHappened();
).MustHaveHappened();
}

[Test]
Expand All @@ -179,17 +174,11 @@ public void Registering_delegate_sends_approval_email_with_refactored_tracking_s
// Then
A.CallTo(
() =>
emailService.SendEmail(
A<Email>.That.Matches(
e =>
e.To[0] == ApproverEmail &&
e.Cc.IsNullOrEmpty() &&
e.Bcc.IsNullOrEmpty() &&
e.Subject == "Digital Learning Solutions Registration Requires Approval" &&
e.Body.TextBody.Contains(RefactoredSystemBaseUrl + "/TrackingSystem/Delegates/Approve")
)
notificationDataService.GetAdminRecipientsForCentreNotification(
model.Centre,
4
)
).MustHaveHappened();
).MustHaveHappened();
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,15 @@ INNER JOIN Applications AS applications
}
public IEnumerable<Recipient> GetAdminRecipientsForCentreNotification(int centreId, int notificationId)
{
return connection.Query<Recipient>(
var recipients = connection.Query<Recipient>(

@"SELECT au.Forename as FirstName, au.Surname as LastName, au.Email
FROM NotificationUsers AS nu INNER JOIN
AdminUsers AS au ON nu.AdminUserID = au.AdminID AND au.Active = 1
WHERE (nu.NotificationID = @notificationId) AND (au.CentreID = @centreId OR c.CentreID = @centreId)",
WHERE (nu.NotificationID = @notificationId) AND (au.CentreID = @centreId)",
new { notificationId, centreId }
);
return recipients;
}
}
}