ContentVersion cleanup backoffice UI (#11637) (#11644)

* ContentVersion cleanup backoffice UI (#11637)

* init rollback ui prototype

* add busy state to button, deselect version, add pagination status

* add localisation

* style current version

* disable rollback button when nothing is selected

* stop click event

* Endpoints for paginated content versions.
Light on tests, tight on time.

* Endpoints to "pin" content versions

* camel case json output.
Not sure why json formatter not set for controller, bit risky to add it now

* wire up paging

* wire up pin/unpin

* rename getPagedRollbackVersions to getPagedContentVersions

* prevent selection of current version and current draft

* add current draft and current version to UI

* remove pointer if the row is not selectable

* Improve warning for globally disabled cleanup feature.

* Fix current loses prevent cleanup state on publish.

* Added umbracoLog audit entries for "pin" / "unpin"

* Match v9 defaults for keepVersions settings

* Fix - losing preventCleanup on save current with content changes

* update pin/unpin button labels

* fix pagination bug

* add missing "

* always send culture when a doc type can vary

Co-authored-by: Mads Rasmussen <madsr@hey.com>
# Conflicts:
#	src/Umbraco.Core/ContentEditing/ContentVersionMetaViewModel.cs
#	src/Umbraco.Core/Models/HistoricContentVersionMeta.cs
#	src/Umbraco.Infrastructure/Services/Implement/ContentService.cs
#	src/Umbraco.Tests/Persistence/Repositories/DocumentVersionRepository_Tests_Integration.cs
#	src/Umbraco.Tests/Services/ContentVersionCleanupService_Tests_UnitTests.cs
#	src/Umbraco.Web.BackOffice/Controllers/ContentController.cs
#	src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js
#	src/Umbraco.Web.UI/config/umbracoSettings.Release.config
#	src/Umbraco.Web.UI/umbraco/config/lang/en.xml
#	src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml
#	src/Umbraco.Web/Umbraco.Web.csproj

* Added tests

* Misc - missed translation update

* Bugfix - DocumentVersionRepository.Get should not join culture variation

* Bugfix - Missing write lock

* Removed unnecessary view model

* Misc - kill some warnings

* Misc - Kill some more warnings

* Fixed cypress rollback test

* Bugfix - Policy returns items to delete not items to keep.
Switch to inverse behavior.

# Conflicts:
#	src/Umbraco.Tests/Services/DefaultContentVersionCleanupPolicy_Tests_UnitTests.cs

Co-authored-by: Paul Johnson <pmj@umbraco.com>
This commit is contained in:
Bjarke Berg
2021-11-16 13:04:31 +01:00
committed by GitHub
parent e2fdf43a7f
commit b0a4a92f57
26 changed files with 902 additions and 216 deletions

View File

@@ -343,13 +343,7 @@ context('Content', () => {
// Rollback
cy.get('.umb-box-header :button').click();
cy.get('.umb-box-content > div > .input-block-level')
.find('option[label*=' + new Date().getDate() + ']')
.then(elements => {
const option = elements[elements.length - 1].getAttribute('value');
cy.get('.umb-box-content > div > .input-block-level')
.select(option);
});
cy.get('.-selectable.cursor-pointer:first').click();
cy.get('.umb-editor-footer-content__right-side > [button-style="success"] > .umb-button > .btn-success').click();

View File

@@ -2,6 +2,7 @@ using System.Diagnostics;
using System.Linq;
using NUnit.Framework;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement;
@@ -31,7 +32,6 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
var contentType = ContentTypeBuilder.CreateSimpleContentType("umbTextpage", "Textpage", defaultTemplateId: template.Id);
ContentTypeService.Save(contentType);
ContentTypeService.Save(contentType);
var content = ContentBuilder.CreateSimpleContent(contentType);
@@ -130,5 +130,75 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
});
}
}
[Test]
public void GetPagedItemsByContentId_WithInvariantCultureContent_ReturnsPaginatedResults()
{
Template template = TemplateBuilder.CreateTextPageTemplate();
FileService.SaveTemplate(template);
var contentType = ContentTypeBuilder.CreateSimpleContentType("umbTextpage", "Textpage", defaultTemplateId: template.Id);
ContentTypeService.Save(contentType);
var content = ContentBuilder.CreateSimpleContent(contentType);
ContentService.SaveAndPublish(content); // Draft + Published
ContentService.SaveAndPublish(content); // New Draft
using (ScopeProvider.CreateScope())
{
var sut = new DocumentVersionRepository((IScopeAccessor)ScopeProvider);
var page1 = sut.GetPagedItemsByContentId(content.Id, 0, 2, out var page1Total);
var page2 = sut.GetPagedItemsByContentId(content.Id, 1, 2, out var page2Total);
Assert.Multiple(() =>
{
Assert.AreEqual(2, page1.Count());
Assert.AreEqual(3, page1Total);
Assert.AreEqual(1, page2.Count());
Assert.AreEqual(3, page2Total);
});
}
}
[Test]
public void GetPagedItemsByContentId_WithVariantCultureContent_ReturnsPaginatedResults()
{
Template template = TemplateBuilder.CreateTextPageTemplate();
FileService.SaveTemplate(template);
var contentType = ContentTypeBuilder.CreateSimpleContentType("umbTextpage", "Textpage", defaultTemplateId: template.Id);
contentType.Variations = ContentVariation.Culture;
foreach (var propertyType in contentType.PropertyTypes)
{
propertyType.Variations = ContentVariation.Culture;
}
FileService.SaveTemplate(contentType.DefaultTemplate);
ContentTypeService.Save(contentType);
var content = ContentBuilder.CreateSimpleContent(contentType, "foo", culture:"en-US");
content.SetCultureName("foo", "en-US");
ContentService.SaveAndPublish(content, "en-US"); // Draft + Published
ContentService.SaveAndPublish(content, "en-US"); // New Draft
using (ScopeProvider.CreateScope())
{
var sut = new DocumentVersionRepository((IScopeAccessor)ScopeProvider);
var page1 = sut.GetPagedItemsByContentId(content.Id, 0, 2, out var page1Total, 1);
var page2 = sut.GetPagedItemsByContentId(content.Id, 1, 2, out var page2Total, 1);
Assert.Multiple(() =>
{
Assert.AreEqual(2, page1.Count());
Assert.AreEqual(3, page1Total);
Assert.AreEqual(1, page2.Count());
Assert.AreEqual(3, page2Total);
});
}
}
}
}

View File

@@ -24,7 +24,7 @@ namespace Umbraco.Tests.Services
[Frozen] Mock<IScopedNotificationPublisher> eventAggregator,
[Frozen] Mock<IContentVersionCleanupPolicy> policy,
[Frozen] Mock<IDocumentVersionRepository> documentVersionRepository,
List<HistoricContentVersionMeta> someHistoricVersions,
List<ContentVersionMeta> someHistoricVersions,
DateTime aDateTime,
ContentVersionService sut)
{
@@ -38,7 +38,7 @@ namespace Umbraco.Tests.Services
.Returns(someHistoricVersions);
// # Act
IReadOnlyCollection<HistoricContentVersionMeta> report = sut.PerformContentVersionCleanup(aDateTime);
IReadOnlyCollection<ContentVersionMeta> report = sut.PerformContentVersionCleanup(aDateTime);
Assert.Multiple(() =>
{
@@ -53,7 +53,7 @@ namespace Umbraco.Tests.Services
[Frozen] Mock<IScopedNotificationPublisher> eventAggregator,
[Frozen] Mock<IContentVersionCleanupPolicy> policy,
[Frozen] Mock<IDocumentVersionRepository> documentVersionRepository,
List<HistoricContentVersionMeta> someHistoricVersions,
List<ContentVersionMeta> someHistoricVersions,
DateTime aDateTime,
ContentVersionService sut)
{
@@ -78,7 +78,7 @@ namespace Umbraco.Tests.Services
[Frozen] Mock<IScopedNotificationPublisher> eventAggregator,
[Frozen] Mock<IContentVersionCleanupPolicy> policy,
[Frozen] Mock<IDocumentVersionRepository> documentVersionRepository,
List<HistoricContentVersionMeta> someHistoricVersions,
List<ContentVersionMeta> someHistoricVersions,
DateTime aDateTime,
ContentVersionService sut)
{
@@ -104,7 +104,7 @@ namespace Umbraco.Tests.Services
[Frozen] Mock<IScopedNotificationPublisher> eventAggregator,
[Frozen] Mock<IContentVersionCleanupPolicy> policy,
[Frozen] Mock<IDocumentVersionRepository> documentVersionRepository,
List<HistoricContentVersionMeta> someHistoricVersions,
List<ContentVersionMeta> someHistoricVersions,
DateTime aDateTime,
ContentVersionService sut)
{
@@ -115,8 +115,8 @@ namespace Umbraco.Tests.Services
.Setup(x => x.PublishCancelable(It.IsAny<ICancelableNotification>()))
.Returns(false);
policy.Setup(x => x.Apply(It.IsAny<DateTime>(), It.IsAny<IEnumerable<HistoricContentVersionMeta>>()))
.Returns<DateTime, IEnumerable<HistoricContentVersionMeta>>((_, items) => items.Take(1));
policy.Setup(x => x.Apply(It.IsAny<DateTime>(), It.IsAny<IEnumerable<ContentVersionMeta>>()))
.Returns<DateTime, IEnumerable<ContentVersionMeta>>((_, items) => items.Take(1));
// # Act
var report = sut.PerformContentVersionCleanup(aDateTime);
@@ -138,7 +138,7 @@ namespace Umbraco.Tests.Services
[Frozen] Mock<IScopedNotificationPublisher> eventAggregator,
[Frozen] Mock<IContentVersionCleanupPolicy> policy,
[Frozen] Mock<IDocumentVersionRepository> documentVersionRepository,
List<HistoricContentVersionMeta> someHistoricVersions,
List<ContentVersionMeta> someHistoricVersions,
DateTime aDateTime,
ContentVersionService sut)
{
@@ -151,8 +151,8 @@ namespace Umbraco.Tests.Services
var filteredSet = someHistoricVersions.Take(1);
policy.Setup(x => x.Apply(It.IsAny<DateTime>(), It.IsAny<IEnumerable<HistoricContentVersionMeta>>()))
.Returns<DateTime, IEnumerable<HistoricContentVersionMeta>>((_, items) => filteredSet);
policy.Setup(x => x.Apply(It.IsAny<DateTime>(), It.IsAny<IEnumerable<ContentVersionMeta>>()))
.Returns<DateTime, IEnumerable<ContentVersionMeta>>((_, items) => filteredSet);
// # Act
var report = sut.PerformContentVersionCleanup(aDateTime);

View File

@@ -25,10 +25,10 @@ namespace Umbraco.Tests.Services
{
var versionId = 0;
var historicItems = new List<HistoricContentVersionMeta>
var historicItems = new List<ContentVersionMeta>
{
new HistoricContentVersionMeta(versionId: ++versionId, contentId: 1, contentTypeId: 1, versionDate: DateTime.Today.AddHours(-1)),
new HistoricContentVersionMeta(versionId: ++versionId, contentId: 1, contentTypeId: 1, versionDate: DateTime.Today.AddHours(-1)),
new ContentVersionMeta(versionId: ++versionId, contentId: 1, contentTypeId: 1, -1, versionDate: DateTime.Today.AddHours(-1), false, false, false, null),
new ContentVersionMeta(versionId: ++versionId, contentId: 1, contentTypeId: 1, -1, versionDate: DateTime.Today.AddHours(-1), false, false, false, null),
};
contentSettings.Setup(x => x.Value).Returns(new ContentSettings()
@@ -60,10 +60,10 @@ namespace Umbraco.Tests.Services
{
var versionId = 0;
var historicItems = new List<HistoricContentVersionMeta>
var historicItems = new List<ContentVersionMeta>
{
new HistoricContentVersionMeta(versionId: ++versionId, contentId: 1, contentTypeId: 1, versionDate: DateTime.Today.AddHours(-1)),
new HistoricContentVersionMeta(versionId: ++versionId, contentId: 1, contentTypeId: 1, versionDate: DateTime.Today.AddHours(-1)),
new ContentVersionMeta(versionId: ++versionId, contentId: 1, contentTypeId: 1, -1, versionDate: DateTime.Today.AddHours(-1), false, false, false, null),
new ContentVersionMeta(versionId: ++versionId, contentId: 1, contentTypeId: 1, -1, versionDate: DateTime.Today.AddHours(-1), false, false, false, null),
};
contentSettings.Setup(x => x.Value).Returns(new ContentSettings()
@@ -93,21 +93,22 @@ namespace Umbraco.Tests.Services
[Frozen] Mock<IOptions<ContentSettings>> contentSettings,
DefaultContentVersionCleanupPolicy sut)
{
var historicItems = new List<HistoricContentVersionMeta>
var historicItems = new List<ContentVersionMeta>
{
new HistoricContentVersionMeta(versionId: 1, contentId: 1, contentTypeId: 1, versionDate: DateTime.Today.AddHours(-3)),
new HistoricContentVersionMeta(versionId: 2, contentId: 1, contentTypeId: 1, versionDate: DateTime.Today.AddHours(-2)),
new HistoricContentVersionMeta(versionId: 3, contentId: 1, contentTypeId: 1, versionDate: DateTime.Today.AddHours(-1)),
new ContentVersionMeta(versionId: 1, contentId: 1, contentTypeId: 1, -1, versionDate: DateTime.Today.AddHours(-3), false, false, false, null),
new ContentVersionMeta(versionId: 2, contentId: 1, contentTypeId: 1, -1, versionDate: DateTime.Today.AddHours(-2), false, false, false, null),
new ContentVersionMeta(versionId: 3, contentId: 1, contentTypeId: 1, -1, versionDate: DateTime.Today.AddHours(-1), false, false, false, null),
new HistoricContentVersionMeta(versionId: 4, contentId: 1, contentTypeId: 1, versionDate: DateTime.Today.AddDays(-1).AddHours(-3)),
new HistoricContentVersionMeta(versionId: 5, contentId: 1, contentTypeId: 1, versionDate: DateTime.Today.AddDays(-1).AddHours(-2)),
new HistoricContentVersionMeta(versionId: 6, contentId: 1, contentTypeId: 1, versionDate: DateTime.Today.AddDays(-1).AddHours(-1)),
new ContentVersionMeta(versionId: 4, contentId: 1, contentTypeId: 1, -1, versionDate: DateTime.Today.AddDays(-1).AddHours(-3), false, false, false, null),
new ContentVersionMeta(versionId: 5, contentId: 1, contentTypeId: 1, -1, versionDate: DateTime.Today.AddDays(-1).AddHours(-2), false, false, false, null),
new ContentVersionMeta(versionId: 6, contentId: 1, contentTypeId: 1, -1, versionDate: DateTime.Today.AddDays(-1).AddHours(-1), false, false, false, null),
// another content
new HistoricContentVersionMeta(versionId: 7, contentId: 2, contentTypeId: 1, versionDate: DateTime.Today.AddHours(-3)),
new HistoricContentVersionMeta(versionId: 8, contentId: 2, contentTypeId: 1, versionDate: DateTime.Today.AddHours(-2)),
new HistoricContentVersionMeta(versionId: 9, contentId: 2, contentTypeId: 1, versionDate: DateTime.Today.AddHours(-1)),
new ContentVersionMeta(versionId: 7, contentId: 2, contentTypeId: 2, -1, versionDate: DateTime.Today.AddHours(-3), false, false, false, null),
new ContentVersionMeta(versionId: 8, contentId: 2, contentTypeId: 2, -1, versionDate: DateTime.Today.AddHours(-2), false, false, false, null),
new ContentVersionMeta(versionId: 9, contentId: 2, contentTypeId: 2, -1, versionDate: DateTime.Today.AddHours(-1), false, false, false, null),
};
contentSettings.Setup(x => x.Value).Returns(new ContentSettings()
{
ContentVersionCleanupPolicy = new Cms.Core.Configuration.Models.ContentVersionCleanupPolicySettings()
@@ -126,12 +127,16 @@ namespace Umbraco.Tests.Services
var results = sut.Apply(DateTime.Today, historicItems).ToList();
// Keep latest per day for 3 days per content type
// 2 content types, one of which has 2 days of entries, the other only a single day
Assert.Multiple(() =>
{
Assert.AreEqual(3, results.Count);
Assert.True(results.Exists(x => x.VersionId == 3));
Assert.True(results.Exists(x => x.VersionId == 6));
Assert.True(results.Exists(x => x.VersionId == 9));
Assert.AreEqual(6, results.Count);
Assert.AreEqual(4, results.Count(x => x.ContentTypeId == 1));
Assert.AreEqual(2, results.Count(x => x.ContentTypeId == 2));
Assert.False(results.Any(x => x.VersionId == 9)); // Most recent for content type 2
Assert.False(results.Any(x => x.VersionId == 3)); // Most recent for content type 1 today
Assert.False(results.Any(x => x.VersionId == 6)); // Most recent for content type 1 yesterday
});
}
@@ -141,15 +146,15 @@ namespace Umbraco.Tests.Services
[Frozen] Mock<IOptions<ContentSettings>> contentSettings,
DefaultContentVersionCleanupPolicy sut)
{
var historicItems = new List<HistoricContentVersionMeta>
var historicItems = new List<ContentVersionMeta>
{
new HistoricContentVersionMeta(versionId: 1, contentId: 1, contentTypeId: 1, versionDate: DateTime.Today.AddHours(-3)),
new HistoricContentVersionMeta(versionId: 2, contentId: 1, contentTypeId: 1, versionDate: DateTime.Today.AddHours(-2)),
new HistoricContentVersionMeta(versionId: 3, contentId: 1, contentTypeId: 1, versionDate: DateTime.Today.AddHours(-1)),
new ContentVersionMeta(versionId: 1, contentId: 1, contentTypeId: 1, -1, versionDate: DateTime.Today.AddHours(-3), false, false, false, null),
new ContentVersionMeta(versionId: 2, contentId: 1, contentTypeId: 1, -1, versionDate: DateTime.Today.AddHours(-2), false, false, false, null),
new ContentVersionMeta(versionId: 3, contentId: 1, contentTypeId: 1, -1, versionDate: DateTime.Today.AddHours(-1), false, false, false, null),
// another content & type
new HistoricContentVersionMeta(versionId: 4, contentId: 2, contentTypeId: 2, versionDate: DateTime.Today.AddHours(-3)),
new HistoricContentVersionMeta(versionId: 5, contentId: 2, contentTypeId: 2, versionDate: DateTime.Today.AddHours(-2)),
new HistoricContentVersionMeta(versionId: 6, contentId: 2, contentTypeId: 2, versionDate: DateTime.Today.AddHours(-1)),
new ContentVersionMeta(versionId: 4, contentId: 2, contentTypeId: 2, -1, versionDate: DateTime.Today.AddHours(-3), false, false, false, null),
new ContentVersionMeta(versionId: 5, contentId: 2, contentTypeId: 2, -1, versionDate: DateTime.Today.AddHours(-2), false, false, false, null),
new ContentVersionMeta(versionId: 6, contentId: 2, contentTypeId: 2, -1, versionDate: DateTime.Today.AddHours(-1), false, false, false, null),
};
contentSettings.Setup(x => x.Value).Returns(new ContentSettings()
@@ -182,15 +187,15 @@ namespace Umbraco.Tests.Services
[Frozen] Mock<IOptions<ContentSettings>> contentSettings,
DefaultContentVersionCleanupPolicy sut)
{
var historicItems = new List<HistoricContentVersionMeta>
var historicItems = new List<ContentVersionMeta>
{
new HistoricContentVersionMeta(versionId: 1, contentId: 1, contentTypeId: 1, versionDate: DateTime.Today.AddHours(-3)),
new HistoricContentVersionMeta(versionId: 2, contentId: 1, contentTypeId: 1, versionDate: DateTime.Today.AddHours(-2)),
new HistoricContentVersionMeta(versionId: 3, contentId: 1, contentTypeId: 1, versionDate: DateTime.Today.AddHours(-1)),
new ContentVersionMeta(versionId: 1, contentId: 1, contentTypeId: 1, -1, versionDate: DateTime.Today.AddHours(-3), false, false, false, null),
new ContentVersionMeta(versionId: 2, contentId: 1, contentTypeId: 1, -1, versionDate: DateTime.Today.AddHours(-2), false, false, false, null),
new ContentVersionMeta(versionId: 3, contentId: 1, contentTypeId: 1, -1, versionDate: DateTime.Today.AddHours(-1), false, false, false, null),
// another content & type
new HistoricContentVersionMeta(versionId: 4, contentId: 2, contentTypeId: 2, versionDate: DateTime.Today.AddHours(-3)),
new HistoricContentVersionMeta(versionId: 5, contentId: 2, contentTypeId: 2, versionDate: DateTime.Today.AddHours(-2)),
new HistoricContentVersionMeta(versionId: 6, contentId: 2, contentTypeId: 2, versionDate: DateTime.Today.AddHours(-1)),
new ContentVersionMeta(versionId: 4, contentId: 2, contentTypeId: 2, -1, versionDate: DateTime.Today.AddHours(-3), false, false, false, null),
new ContentVersionMeta(versionId: 5, contentId: 2, contentTypeId: 2, -1, versionDate: DateTime.Today.AddHours(-2), false, false, false, null),
new ContentVersionMeta(versionId: 6, contentId: 2, contentTypeId: 2, -1, versionDate: DateTime.Today.AddHours(-1), false, false, false, null),
};
contentSettings.Setup(x => x.Value).Returns(new ContentSettings()
@@ -223,15 +228,19 @@ namespace Umbraco.Tests.Services
[Frozen] Mock<IOptions<ContentSettings>> contentSettings,
DefaultContentVersionCleanupPolicy sut)
{
var historicItems = new List<HistoricContentVersionMeta>
var historicItems = new List<ContentVersionMeta>
{
new HistoricContentVersionMeta(versionId: 1, contentId: 1, contentTypeId: 1, versionDate: DateTime.Today.AddHours(-3)),
new HistoricContentVersionMeta(versionId: 2, contentId: 1, contentTypeId: 1, versionDate: DateTime.Today.AddHours(-2)),
new HistoricContentVersionMeta(versionId: 3, contentId: 1, contentTypeId: 1, versionDate: DateTime.Today.AddHours(-1)),
new ContentVersionMeta(versionId: 1, contentId: 1, contentTypeId: 1, -1, versionDate: DateTime.Today.AddHours(-3), false, false, false, null),
new ContentVersionMeta(versionId: 2, contentId: 1, contentTypeId: 1, -1, versionDate: DateTime.Today.AddHours(-2), false, false, false, null),
new ContentVersionMeta(versionId: 3, contentId: 1, contentTypeId: 1, -1, versionDate: DateTime.Today.AddHours(-1), false, false, false, null),
// another content
new ContentVersionMeta(versionId: 4, contentId: 2, contentTypeId: 1, -1, versionDate: DateTime.Today.AddHours(-3), false, false, false, null),
new ContentVersionMeta(versionId: 5, contentId: 2, contentTypeId: 1, -1, versionDate: DateTime.Today.AddHours(-2), false, false, false, null),
new ContentVersionMeta(versionId: 6, contentId: 2, contentTypeId: 1, -1, versionDate: DateTime.Today.AddHours(-1), false, false, false, null),
// another content & type
new HistoricContentVersionMeta(versionId: 4, contentId: 2, contentTypeId: 2, versionDate: DateTime.Today.AddHours(-3)),
new HistoricContentVersionMeta(versionId: 5, contentId: 2, contentTypeId: 2, versionDate: DateTime.Today.AddHours(-2)),
new HistoricContentVersionMeta(versionId: 6, contentId: 2, contentTypeId: 2, versionDate: DateTime.Today.AddHours(-1)),
new ContentVersionMeta(versionId: 7, contentId: 3, contentTypeId: 2, -1, versionDate: DateTime.Today.AddHours(-3), false, false, false, null),
new ContentVersionMeta(versionId: 8, contentId: 3, contentTypeId: 2, -1, versionDate: DateTime.Today.AddHours(-2), false, false, false, null),
new ContentVersionMeta(versionId: 9, contentId: 3, contentTypeId: 2, -1, versionDate: DateTime.Today.AddHours(-1), false, false, false, null),
};
contentSettings.Setup(x => x.Value).Returns(new ContentSettings()
@@ -255,10 +264,15 @@ namespace Umbraco.Tests.Services
var results = sut.Apply(DateTime.Today, historicItems).ToList();
// By default no historic versions are kept
// Override policy for content type 2 keeps latest per day for 3 days, no versions retained for content type with id 1
// There were 3 entries for content type 2 all on the same day
// version id 9 is most recent for content type 2, and should be filtered, all the rest should be present.
Assert.Multiple(() =>
{
Assert.AreEqual(3, results.Count(x => x.ContentTypeId == 1));
Assert.AreEqual(6, results.Single(x => x.ContentTypeId == 2).VersionId);
Assert.AreEqual(8, results.Count);
Assert.AreEqual(2, results.Count(x => x.ContentTypeId == 2));
Assert.False(results.Any(x => x.VersionId == 9));
});
}
}

View File

@@ -261,7 +261,8 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Web.BackOffice.Controllers
Mock.Of<ISqlContext>(),
Mock.Of<IJsonSerializer>(),
Mock.Of<IScopeProvider>(),
Mock.Of<IAuthorizationService>()
Mock.Of<IAuthorizationService>(),
Mock.Of<IContentVersionService>()
);
return controller;