From dafcdde715016661f0be48f8f95ebe0a3f286451 Mon Sep 17 00:00:00 2001 From: Jake Fink Date: Fri, 10 Mar 2023 12:53:22 -0500 Subject: [PATCH] [AC-1110] add deleteAnyCollection permission to bulk delete (#2766) * [AC-1110] add deleteAnyCollection permission to bulk delete * [AC-1110] call collection service instead of repo for user collections * [AC-1110] fix tests * [AC-1110] fix more tests --- src/Api/Controllers/CollectionsController.cs | 4 ++-- .../Controllers/CollectionsControllerTests.cs | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Api/Controllers/CollectionsController.cs b/src/Api/Controllers/CollectionsController.cs index 3697c7f4b..4954cf1f2 100644 --- a/src/Api/Controllers/CollectionsController.cs +++ b/src/Api/Controllers/CollectionsController.cs @@ -204,12 +204,12 @@ public class CollectionsController : Controller { var orgId = new Guid(model.OrganizationId); var collectionIds = model.Ids.Select(i => new Guid(i)); - if (!await _currentContext.DeleteAssignedCollections(orgId)) + if (!await _currentContext.DeleteAssignedCollections(orgId) && !await _currentContext.DeleteAnyCollection(orgId)) { throw new NotFoundException(); } - var userCollections = await _collectionRepository.GetManyByUserIdAsync(_currentContext.UserId.Value); + var userCollections = await _collectionService.GetOrganizationCollections(orgId); var filteredCollections = userCollections.Where(c => collectionIds.Contains(c.Id) && c.OrganizationId == orgId); if (!filteredCollections.Any()) diff --git a/test/Api.Test/Controllers/CollectionsControllerTests.cs b/test/Api.Test/Controllers/CollectionsControllerTests.cs index d056f4240..8a3f944ff 100644 --- a/test/Api.Test/Controllers/CollectionsControllerTests.cs +++ b/test/Api.Test/Controllers/CollectionsControllerTests.cs @@ -148,7 +148,7 @@ public class CollectionsControllerTests OrganizationId = orgId.ToString() }; - var collections = new List + var collections = new List { new CollectionDetails { @@ -170,8 +170,8 @@ public class CollectionsControllerTests .UserId .Returns(user.Id); - sutProvider.GetDependency() - .GetManyByUserIdAsync(user.Id) + sutProvider.GetDependency() + .GetOrganizationCollections(orgId) .Returns(collections); // Act @@ -219,7 +219,7 @@ public class CollectionsControllerTests OrganizationId = orgId.ToString() }; - var collections = new List + var collections = new List { new CollectionDetails { @@ -236,8 +236,8 @@ public class CollectionsControllerTests .UserId .Returns(user.Id); - sutProvider.GetDependency() - .GetManyByUserIdAsync(user.Id) + sutProvider.GetDependency() + .GetOrganizationCollections(orgId) .Returns(collections); // Act