Skip to content

Commit

Permalink
Merge pull request #4309 from dfe-analytical-services/EES-4426
Browse files Browse the repository at this point in the history
EES-4426 Remove MethodologyVersion.InternalReleaseNote
  • Loading branch information
Mark Youngman authored Sep 20, 2023
2 parents 4cfcb5f + 4f8c705 commit 82377f2
Show file tree
Hide file tree
Showing 11 changed files with 2,088 additions and 53 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 Down Expand Up @@ -237,7 +236,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 Down Expand Up @@ -604,12 +602,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,7 +619,6 @@ 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);
Expand Down Expand Up @@ -702,13 +697,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,7 +716,6 @@ 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);
Expand Down Expand Up @@ -886,7 +878,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 Down Expand Up @@ -1129,11 +1120,10 @@ public async Task UpdateApprovalStatus_ApprovingUsingWithReleaseStrategy_Release
}

[Fact]
public async Task UpdateApprovalStatus_UnapprovingMethodology()
public async Task UpdateApprovalStatus_MovingApprovedMethodologyToDraft()
{
var methodologyVersion = new MethodologyVersion
{
InternalReleaseNote = "Test approval",
Published = null,
PublishingStrategy = Immediately,
Status = Approved,
Expand Down Expand Up @@ -1189,7 +1179,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,7 +1196,6 @@ 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);
Expand All @@ -1220,7 +1208,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 +1301,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,7 +1317,6 @@ 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);
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,21 @@ public async Task GetMethodology()
AlternativeTitle = "Alternative title"
};

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

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 +1140,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 +1155,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 +1178,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 +1186,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
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,6 @@ public async Task DeleteRelease()
{
OwningPublicationTitle = "Methodology scheduled with this Release"
},
InternalReleaseNote = "A note"
};

// This Methodology has nothing to do with the Release being deleted.
Expand All @@ -1146,8 +1145,8 @@ public async Task DeleteRelease()
ScheduledWithReleaseId = Guid.NewGuid(),
Methodology = new Methodology
{
OwningPublicationTitle = "Methodology scheduled with another Release"
}
OwningPublicationTitle = "Methodology scheduled with another Release",
},
};

var userReleaseRole = new UserReleaseRole
Expand Down Expand Up @@ -1313,13 +1312,12 @@ public async Task DeleteRelease()

// Assert that Methodologies that were scheduled to go out with this Release are no longer scheduled
// to do so
var retrievedMethodology = context.MethodologyVersions.Single(m => m.Id == methodologyScheduledWithRelease.Id);
Assert.True(retrievedMethodology.ScheduledForPublishingImmediately);
Assert.Null(retrievedMethodology.ScheduledWithReleaseId);
Assert.Null(retrievedMethodology.InternalReleaseNote);
Assert.Equal(MethodologyApprovalStatus.Draft, retrievedMethodology.Status);
var retrievedMethodologyVersion = context.MethodologyVersions.Single(m => m.Id == methodologyScheduledWithRelease.Id);
Assert.True(retrievedMethodologyVersion.ScheduledForPublishingImmediately);
Assert.Null(retrievedMethodologyVersion.ScheduledWithReleaseId);
Assert.Equal(MethodologyApprovalStatus.Draft, retrievedMethodologyVersion.Status);
Assert.InRange(DateTime.UtcNow
.Subtract(retrievedMethodology.Updated!.Value).Milliseconds, 0, 1500);
.Subtract(retrievedMethodologyVersion.Updated!.Value).Milliseconds, 0, 1500);

// Assert that Methodologies that were scheduled to go out with other Releases remain unaffected
var unrelatedMethodology = context.MethodologyVersions.Single(m => m.Id == methodologyScheduledWithAnotherRelease.Id);
Expand Down
Loading

0 comments on commit 82377f2

Please sign in to comment.