diff --git a/src/Core/Services/Implementations/GroupService.cs b/src/Core/Services/Implementations/GroupService.cs index c637fd0ce0..d5f0ebb944 100644 --- a/src/Core/Services/Implementations/GroupService.cs +++ b/src/Core/Services/Implementations/GroupService.cs @@ -61,7 +61,16 @@ public class GroupService : IGroupService else { group.RevisionDate = DateTime.UtcNow; - await _groupRepository.ReplaceAsync(group, collections ?? new List()); + + if (collections == null) + { + await _groupRepository.ReplaceAsync(group); + } + else + { + await _groupRepository.ReplaceAsync(group, collections); + } + await _eventService.LogGroupEventAsync(group, Enums.EventType.Group_Updated); } } diff --git a/test/Core.Test/Services/GroupServiceTests.cs b/test/Core.Test/Services/GroupServiceTests.cs index 80660af17d..45cb01ff76 100644 --- a/test/Core.Test/Services/GroupServiceTests.cs +++ b/test/Core.Test/Services/GroupServiceTests.cs @@ -64,6 +64,20 @@ public class GroupServiceTests Assert.True(group.RevisionDate - DateTime.UtcNow < TimeSpan.FromSeconds(1)); } + [Theory, BitAutoData] + public async Task SaveAsync_NonDefaultGroupId_ReplaceGroupInRepository_NoCollections(Group group, Organization organization, SutProvider sutProvider) + { + organization.UseGroups = true; + sutProvider.GetDependency().GetByIdAsync(organization.Id).Returns(organization); + + await sutProvider.Sut.SaveAsync(group, null); + + await sutProvider.GetDependency().Received().ReplaceAsync(group); + await sutProvider.GetDependency().Received() + .LogGroupEventAsync(group, EventType.Group_Updated); + Assert.True(group.RevisionDate - DateTime.UtcNow < TimeSpan.FromSeconds(1)); + } + [Theory, BitAutoData] public async Task SaveAsync_NonExistingOrganizationId_ThrowsBadRequest(Group group, SutProvider sutProvider) {