Skip to content

Commit 38272a5

Browse files
test: verify video review is restored and prevent archive timestamp overwrite
1 parent eaf691a commit 38272a5

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

VictoryCenter/VictoryCenter.BLL/Commands/Admin/VideoReviews/Delete/DeleteVideoReviewHandler.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ public async Task<Result<long>> Handle(DeleteVideoReviewCommand request, Cancell
3939
return Result.Fail<long>(ErrorMessagesConstants.NotFound(request.Id, typeof(VideoReview)));
4040
}
4141

42+
if (entity.IsArchived)
43+
{
44+
return Result.Ok(entity.Id);
45+
}
46+
4247
entity.IsArchived = true;
4348
entity.ArchivedAt = _timeProvider.GetUtcNow();
4449

VictoryCenter/VictoryCenter.IntegrationTests/ControllerTests/VideoReviews/VideoReviewManagementTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,11 @@ public async Task VideoReviewManagement_ShouldSupportAuthorizedCrud()
8484
Assert.Equal(HttpStatusCode.OK, restoreResponse.StatusCode);
8585
var restoredId = await restoreResponse.Content.ReadFromJsonAsync<long>();
8686
Assert.Equal(created.Id, restoredId);
87-
Assert.False(await Fixture.DbContext.VideoReviews
87+
var restoredEntity = await Fixture.DbContext.VideoReviews
8888
.AsNoTracking()
89-
.AnyAsync(item => item.Id == created.Id && item.IsArchived));
89+
.SingleAsync(item => item.Id == created.Id);
90+
Assert.False(restoredEntity.IsArchived);
91+
Assert.Null(restoredEntity.ArchivedAt);
9092
}
9193

9294
[Fact]

0 commit comments

Comments
 (0)