Skip to content

Commit

Permalink
EES-4426 Changes in response to PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mmyoungman committed Sep 18, 2023
1 parent 84c1d6f commit 4f8c705
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,6 @@ public async Task UpdateApprovalStatus_MethodologyHasImages()
Assert.Equal(Immediately, updatedMethodology.PublishingStrategy);
Assert.True(updatedMethodology.Updated.HasValue);
Assert.InRange(DateTime.UtcNow.Subtract(updatedMethodology.Updated!.Value).Milliseconds, 0, 1500);

var statusList = await context
.MethodologyStatus
.Where(ms => ms.MethodologyVersionId == methodologyVersion.Id)
.ToListAsync();
var status = Assert.Single(statusList);
Assert.Equal(methodologyVersion.Id, status.MethodologyVersionId);
Assert.Equal("Test approval", status.InternalReleaseNote);
Assert.Equal(Approved, status.ApprovalStatus);
Assert.InRange(DateTime.UtcNow.Subtract(status.Created!.Value).Milliseconds, 0, 1500);
Assert.Equal(UserId, status.CreatedById);
}
}

Expand Down Expand Up @@ -265,17 +254,6 @@ public async Task UpdateApprovalStatus_ApprovingMethodologyWithUnusedImages()
Assert.Equal(Immediately, updatedMethodology.PublishingStrategy);
Assert.True(updatedMethodology.Updated.HasValue);
Assert.InRange(DateTime.UtcNow.Subtract(updatedMethodology.Updated!.Value).Milliseconds, 0, 1500);

var statusList = await context
.MethodologyStatus
.Where(ms => ms.MethodologyVersionId == methodologyVersion.Id)
.ToListAsync();
var status = Assert.Single(statusList);
Assert.Equal(methodologyVersion.Id, status.MethodologyVersionId);
Assert.Equal("Test approval", status.InternalReleaseNote);
Assert.Equal(Approved, status.ApprovalStatus);
Assert.InRange(DateTime.UtcNow.Subtract(status.Created!.Value).Milliseconds, 0, 1500);
Assert.Equal(UserId, status.CreatedById);
}
}

Expand Down Expand Up @@ -644,17 +622,6 @@ public async Task UpdateApprovalStatus_ApprovingUsingImmediateStrategy_NotCurren
Assert.True(updatedMethodologyVersion.Updated.HasValue);
Assert.InRange(DateTime.UtcNow.Subtract(updatedMethodologyVersion.Updated!.Value).Milliseconds, 0, 1500);
Assert.Null(updatedMethodologyVersion.Methodology.LatestPublishedVersionId);

var statusList = await context
.MethodologyStatus
.Where(ms => ms.MethodologyVersionId == methodologyVersion.Id)
.ToListAsync();
var status = Assert.Single(statusList);
Assert.Equal(methodologyVersion.Id, status.MethodologyVersionId);
Assert.Equal("Test approval", status.InternalReleaseNote);
Assert.Equal(Approved, status.ApprovalStatus);
Assert.InRange(DateTime.UtcNow.Subtract(status.Created!.Value).Milliseconds, 0, 1500);
Assert.Equal(UserId, status.CreatedById);
}
}

Expand Down Expand Up @@ -752,17 +719,6 @@ public async Task UpdateApprovalStatus_ApprovingUsingImmediateStrategy()
Assert.True(updatedMethodologyVersion.Updated.HasValue);
Assert.InRange(DateTime.UtcNow.Subtract(updatedMethodologyVersion.Updated!.Value).Milliseconds, 0, 1500);
Assert.Equal(methodologyVersion.Id, updatedMethodologyVersion.Methodology.LatestPublishedVersionId);

var statusList = await context
.MethodologyStatus
.Where(ms => ms.MethodologyVersionId == methodologyVersion.Id)
.ToListAsync();
var status = Assert.Single(statusList);
Assert.Equal(methodologyVersion.Id, status.MethodologyVersionId);
Assert.Equal("Test approval", status.InternalReleaseNote);
Assert.Equal(Approved, status.ApprovalStatus);
Assert.InRange(DateTime.UtcNow.Subtract(status.Created!.Value).Milliseconds, 0, 1500);
Assert.Equal(UserId, status.CreatedById);
}
}

Expand Down Expand Up @@ -946,17 +902,6 @@ public async Task UpdateApprovalStatus_ApprovingUsingWithReleaseStrategy_NonLive
Assert.True(updatedMethodologyVersion.Updated.HasValue);
Assert.InRange(DateTime.UtcNow.Subtract(updatedMethodologyVersion.Updated!.Value).Milliseconds, 0, 1500);
Assert.Null(updatedMethodologyVersion.Methodology.LatestPublishedVersionId);

var statusList = await context
.MethodologyStatus
.Where(ms => ms.MethodologyVersionId == methodologyVersion.Id)
.ToListAsync();
var status = Assert.Single(statusList);
Assert.Equal(methodologyVersion.Id, status.MethodologyVersionId);
Assert.Equal("Test approval", status.InternalReleaseNote);
Assert.Equal(Approved, status.ApprovalStatus);
Assert.InRange(DateTime.UtcNow.Subtract(status.Created!.Value).Milliseconds, 0, 1500);
Assert.Equal(UserId, status.CreatedById);
}
}

Expand Down Expand Up @@ -1175,7 +1120,7 @@ public async Task UpdateApprovalStatus_ApprovingUsingWithReleaseStrategy_Release
}

[Fact]
public async Task UpdateApprovalStatus_UnapprovingMethodology()
public async Task UpdateApprovalStatus_MovingApprovedMethodologyToDraft()
{
var methodologyVersion = new MethodologyVersion
{
Expand Down Expand Up @@ -1254,17 +1199,6 @@ public async Task UpdateApprovalStatus_UnapprovingMethodology()
Assert.True(updatedMethodologyVersion.Updated.HasValue);
Assert.InRange(DateTime.UtcNow.Subtract(updatedMethodologyVersion.Updated!.Value).Milliseconds, 0, 1500);
Assert.Null(updatedMethodologyVersion.Methodology.LatestPublishedVersionId);

var statusList = await context
.MethodologyStatus
.Where(ms => ms.MethodologyVersionId == methodologyVersion.Id)
.ToListAsync();
var status = Assert.Single(statusList);
Assert.Equal(methodologyVersion.Id, status.MethodologyVersionId);
Assert.Equal("A release note", status.InternalReleaseNote);
Assert.Equal(Draft, status.ApprovalStatus);
Assert.InRange(DateTime.UtcNow.Subtract(status.Created!.Value).Milliseconds, 0, 1500);
Assert.Equal(UserId, status.CreatedById);
}
}

Expand Down Expand Up @@ -1386,17 +1320,6 @@ public async Task UpdateApprovalStatus_SubmitDraftForHigherReview()
Assert.True(updatedMethodologyVersion.Updated.HasValue);
Assert.InRange(DateTime.UtcNow.Subtract(updatedMethodologyVersion.Updated!.Value).Milliseconds, 0, 1500);
Assert.Null(updatedMethodologyVersion.Methodology.LatestPublishedVersionId);

var statusList = await context
.MethodologyStatus
.Where(ms => ms.MethodologyVersionId == methodologyVersion.Id)
.ToListAsync();
var status = Assert.Single(statusList);
Assert.Equal(methodologyVersion.Id, status.MethodologyVersionId);
Assert.Equal("A release note", status.InternalReleaseNote);
Assert.Equal(HigherLevelReview, status.ApprovalStatus);
Assert.InRange(DateTime.UtcNow.Subtract(status.Created!.Value).Milliseconds, 0, 1500);
Assert.Equal(UserId, status.CreatedById);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,7 @@ public async Task GetMethodology()
{
MethodologyVersion = methodologyVersion,
InternalReleaseNote = "Test approval",
ApprovalStatus = Approved,
};

var contentDbContextId = Guid.NewGuid().ToString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ await _context.Entry(loadedMethodologyVersion)

var viewModel = _mapper.Map<MethodologyVersionViewModel>(loadedMethodologyVersion);

viewModel.InternalReleaseNote = await GetLatestInternalNote(loadedMethodologyVersion);
viewModel.InternalReleaseNote = await GetLatestInternalReleaseNote(loadedMethodologyVersion.Id);

viewModel.OwningPublication = owningPublication;
viewModel.OtherPublications = otherPublications;
Expand Down Expand Up @@ -427,11 +427,11 @@ private async Task<Either<ActionResult, Unit>> DeleteVersion(MethodologyVersion
});
}

private async Task<string?> GetLatestInternalNote(MethodologyVersion methodologyVersion)
private async Task<string?> GetLatestInternalReleaseNote(Guid methodologyVersionId)
{
// NOTE: Gets latest internal note for this version, not for the entire methodology
return await _context.MethodologyStatus
.Where(ms => methodologyVersion.Id == ms.MethodologyVersionId)
.Where(ms => methodologyVersionId == ms.MethodologyVersionId)
.OrderByDescending(ms => ms.Created)
.Select(ms => ms.InternalReleaseNote)
.FirstOrDefaultAsync();
Expand Down

0 comments on commit 4f8c705

Please sign in to comment.