Skip to content

Commit

Permalink
EES-4426 Remove MethodologyVersion.InternalReleaseNote
Browse files Browse the repository at this point in the history
  • Loading branch information
mmyoungman committed Sep 18, 2023
1 parent d4b1487 commit 84c1d6f
Show file tree
Hide file tree
Showing 11 changed files with 2,163 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ public async Task UpdateApprovalStatus_MethodologyHasImages()
VerifyAllMocks(contentService, methodologyVersionRepository);

Assert.Equal(methodologyVersion.Id, updatedMethodologyVersion.Id);
Assert.Equal("Test approval", updatedMethodologyVersion.InternalReleaseNote);
Assert.Null(updatedMethodologyVersion.Published);
Assert.Equal(Immediately, updatedMethodologyVersion.PublishingStrategy);
Assert.Null(updatedMethodologyVersion.ScheduledWithRelease);
Expand All @@ -139,6 +138,17 @@ 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 @@ -237,7 +247,6 @@ public async Task UpdateApprovalStatus_ApprovingMethodologyWithUnusedImages()
VerifyAllMocks(contentService, imageService, methodologyVersionRepository);

Assert.Equal(methodologyVersion.Id, updatedMethodologyVersion.Id);
Assert.Equal("Test approval", updatedMethodologyVersion.InternalReleaseNote);
Assert.Null(updatedMethodologyVersion.Published);
Assert.Equal(Immediately, updatedMethodologyVersion.PublishingStrategy);
Assert.Null(updatedMethodologyVersion.ScheduledWithRelease);
Expand All @@ -256,6 +265,17 @@ 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 @@ -604,12 +624,10 @@ public async Task UpdateApprovalStatus_ApprovingUsingImmediateStrategy_NotCurren
VerifyAllMocks(contentService, methodologyVersionRepository);

Assert.Equal(methodologyVersion.Id, updatedMethodologyVersion.Id);
Assert.Equal("Test approval", updatedMethodologyVersion.InternalReleaseNote);
Assert.False(updatedMethodologyVersion.Published.HasValue);
Assert.Equal(Immediately, updatedMethodologyVersion.PublishingStrategy);
Assert.Null(updatedMethodologyVersion.ScheduledWithRelease);
Assert.Equal(request.Status, updatedMethodologyVersion.Status);
Assert.Equal(request.LatestInternalReleaseNote, updatedMethodologyVersion.InternalReleaseNote);
Assert.Null(updatedMethodologyVersion.Methodology.LatestPublishedVersionId);
}

Expand All @@ -623,10 +641,20 @@ public async Task UpdateApprovalStatus_ApprovingUsingImmediateStrategy_NotCurren
Assert.False(updatedMethodologyVersion.Published.HasValue);
Assert.Equal(Approved, updatedMethodologyVersion.Status);
Assert.Equal(Immediately, updatedMethodologyVersion.PublishingStrategy);
Assert.Equal(request.LatestInternalReleaseNote, updatedMethodologyVersion.InternalReleaseNote);
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 @@ -702,13 +730,11 @@ public async Task UpdateApprovalStatus_ApprovingUsingImmediateStrategy()
methodologyCacheService);

Assert.Equal(methodologyVersion.Id, updatedMethodologyVersion.Id);
Assert.Equal("Test approval", updatedMethodologyVersion.InternalReleaseNote);
Assert.True(updatedMethodologyVersion.Published.HasValue);
Assert.InRange(DateTime.UtcNow.Subtract(updatedMethodologyVersion.Published!.Value).Milliseconds, 0, 1500);
Assert.Equal(Immediately, updatedMethodologyVersion.PublishingStrategy);
Assert.Null(updatedMethodologyVersion.ScheduledWithRelease);
Assert.Equal(request.Status, updatedMethodologyVersion.Status);
Assert.Equal(request.LatestInternalReleaseNote, updatedMethodologyVersion.InternalReleaseNote);
Assert.Equal(methodologyVersion.Id, updatedMethodologyVersion.Methodology.LatestPublishedVersionId);
}

Expand All @@ -723,10 +749,20 @@ public async Task UpdateApprovalStatus_ApprovingUsingImmediateStrategy()
Assert.InRange(DateTime.UtcNow.Subtract(updatedMethodologyVersion.Published!.Value).Milliseconds, 0, 1500);
Assert.Equal(Approved, updatedMethodologyVersion.Status);
Assert.Equal(Immediately, updatedMethodologyVersion.PublishingStrategy);
Assert.Equal(request.LatestInternalReleaseNote, updatedMethodologyVersion.InternalReleaseNote);
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 @@ -886,7 +922,6 @@ public async Task UpdateApprovalStatus_ApprovingUsingWithReleaseStrategy_NonLive
VerifyAllMocks(contentService, methodologyVersionRepository);

Assert.Equal(methodologyVersion.Id, updatedMethodologyVersion.Id);
Assert.Equal("Test approval", updatedMethodologyVersion.InternalReleaseNote);
Assert.Null(updatedMethodologyVersion.Published);
Assert.Equal(WithRelease, updatedMethodologyVersion.PublishingStrategy);
Assert.Equal(request.Status, updatedMethodologyVersion.Status);
Expand All @@ -911,6 +946,17 @@ 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 @@ -1133,7 +1179,6 @@ public async Task UpdateApprovalStatus_UnapprovingMethodology()
{
var methodologyVersion = new MethodologyVersion
{
InternalReleaseNote = "Test approval",
Published = null,
PublishingStrategy = Immediately,
Status = Approved,
Expand Down Expand Up @@ -1189,7 +1234,6 @@ public async Task UpdateApprovalStatus_UnapprovingMethodology()

Assert.Equal(methodologyVersion.Id, updatedMethodologyVersion.Id);

Assert.Equal("A release note", updatedMethodologyVersion.InternalReleaseNote);
Assert.Null(updatedMethodologyVersion.Published);
Assert.Equal(Immediately, updatedMethodologyVersion.PublishingStrategy);
Assert.Null(updatedMethodologyVersion.ScheduledWithRelease);
Expand All @@ -1207,10 +1251,20 @@ public async Task UpdateApprovalStatus_UnapprovingMethodology()
Assert.Null(updatedMethodologyVersion.Published);
Assert.Equal(Draft, updatedMethodologyVersion.Status);
Assert.Equal(Immediately, updatedMethodologyVersion.PublishingStrategy);
Assert.Equal("A release note", updatedMethodologyVersion.InternalReleaseNote);
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 All @@ -1220,7 +1274,6 @@ public async Task UpdateApprovalStatus_SubmitDraftForHigherReview()
var owningPublicationId = Guid.NewGuid();
var methodologyVersion = new MethodologyVersion
{
InternalReleaseNote = "Test approval",
Published = null,
Status = Draft,
Methodology = new Methodology
Expand Down Expand Up @@ -1314,7 +1367,6 @@ public async Task UpdateApprovalStatus_SubmitDraftForHigherReview()

Assert.Equal(methodologyVersion.Id, updatedMethodologyVersion.Id);

Assert.Equal("A release note", updatedMethodologyVersion.InternalReleaseNote);
Assert.Null(updatedMethodologyVersion.Published);
Assert.Equal(Immediately, updatedMethodologyVersion.PublishingStrategy);
Assert.Null(updatedMethodologyVersion.ScheduledWithRelease);
Expand All @@ -1331,10 +1383,20 @@ public async Task UpdateApprovalStatus_SubmitDraftForHigherReview()

Assert.Null(updatedMethodologyVersion.Published);
Assert.Equal(HigherLevelReview, updatedMethodologyVersion.Status);
Assert.Equal("A release note", updatedMethodologyVersion.InternalReleaseNote);
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 @@ -589,13 +589,19 @@ public async Task GetAdoptableMethodologies()
var methodologyVersion = new MethodologyVersion
{
Methodology = methodology,
InternalReleaseNote = "Test approval",
Published = null,
PublishingStrategy = Immediately,
Status = Draft,
AlternativeTitle = "Alternative title"
};

var methodologyStatus = new MethodologyStatus
{
MethodologyVersion = methodologyVersion,
InternalReleaseNote = "Test approval",
ApprovalStatus = Approved,
};

var adoptingPublication = new Publication();

var contentDbContextId = Guid.NewGuid().ToString();
Expand All @@ -605,6 +611,7 @@ public async Task GetAdoptableMethodologies()
await context.Publications.AddRangeAsync(publication, adoptingPublication);
await context.Methodologies.AddAsync(methodology);
await context.MethodologyVersions.AddAsync(methodologyVersion);
await context.MethodologyStatus.AddAsync(methodologyStatus);
await context.SaveChangesAsync();
}

Expand Down Expand Up @@ -660,7 +667,6 @@ public async Task GetAdoptableMethodologies_NoUnpublishedMethodologies()
{
new()
{
InternalReleaseNote = "Test approval",
Published = null,
PublishingStrategy = Immediately,
Status = Draft,
Expand Down Expand Up @@ -794,7 +800,6 @@ public async Task GetMethodology()
var methodologyVersion = new MethodologyVersion
{
Methodology = methodology,
InternalReleaseNote = "Test approval",
Published = new DateTime(2020, 5, 25),
PublishingStrategy = WithRelease,
ScheduledWithRelease = new Release
Expand All @@ -807,13 +812,20 @@ public async Task GetMethodology()
AlternativeTitle = "Alternative title"
};

var methodologyStatus = new MethodologyStatus
{
MethodologyVersion = methodologyVersion,
InternalReleaseNote = "Test approval",
};

var contentDbContextId = Guid.NewGuid().ToString();

await using (var context = InMemoryApplicationDbContext(contentDbContextId))
{
await context.Methodologies.AddAsync(methodology);
await context.Publications.AddRangeAsync(owningPublication, adoptingPublication1, adoptingPublication2);
await context.MethodologyVersions.AddAsync(methodologyVersion);
await context.MethodologyStatus.AddAsync(methodologyStatus);
await context.SaveChangesAsync();
}

Expand Down Expand Up @@ -1127,7 +1139,6 @@ public async Task ListLatestMethodologyVersions()
Id = Guid.NewGuid(),
Version = 0,
AlternativeTitle = "Methodology 1 Version 1",
InternalReleaseNote = "Methodology 1 Version 1 release note",
Published = new DateTime(2021, 1, 1),
Status = Approved
}
Expand All @@ -1143,7 +1154,6 @@ public async Task ListLatestMethodologyVersions()
Id = Guid.NewGuid(),
Version = 0,
AlternativeTitle = "Methodology 2 Version 1",
InternalReleaseNote = "Methodology 2 Version 1 release note",
Published = new DateTime(2021, 1, 1),
Status = Approved
},
Expand All @@ -1167,7 +1177,6 @@ public async Task ListLatestMethodologyVersions()
Id = Guid.NewGuid(),
Version = 0,
AlternativeTitle = "Methodology 3 Version 1",
InternalReleaseNote = "Methodology 3 Version 1 release note",
Published = new DateTime(2021, 1, 1),
Status = Approved
},
Expand All @@ -1176,7 +1185,6 @@ public async Task ListLatestMethodologyVersions()
Id = Guid.NewGuid(),
Version = 1,
AlternativeTitle = "Methodology 3 Version 2",
InternalReleaseNote = "Methodology 3 Version 2 release note",
Published = new DateTime(2022, 1, 1),
Status = Approved
}
Expand Down
Loading

0 comments on commit 84c1d6f

Please sign in to comment.