diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/en.xml b/src/Umbraco.Web.UI/umbraco/config/lang/en.xml
index 707bb5631558..6922fe803d7b 100644
--- a/src/Umbraco.Web.UI/umbraco/config/lang/en.xml
+++ b/src/Umbraco.Web.UI/umbraco/config/lang/en.xml
@@ -170,6 +170,8 @@
Content sent for publishing for languages: %0%
Sort child items performed by user
%0%
+
Cleanup disabled for version: %0%
+
Cleanup enabled for version: %0%
Copy
Publish
Publish
@@ -183,6 +185,8 @@
Send To Publish
Sort
Custom
+
Save
+
Save
History (all variants)
@@ -1833,7 +1837,7 @@ To manage your website, simply open the Umbraco backoffice and start adding cont
Keep all versions newer than days
Keep latest version per day for days
Prevent cleanup
-
NOTE! The cleanup of historically content versions is disabled globally. These settings will not take effect before it is enabled.
+
NOTE! The content version cleanup feature is disabled globally. These settings will not take effect until it is enabled.
Add language
diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml b/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml
index dbe779223402..4000682ed914 100644
--- a/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml
+++ b/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml
@@ -171,6 +171,8 @@
Content sent for publishing for languages: %0%
Sort child items performed by user
%0%
+
Cleanup disabled for version: %0%
+
Cleanup enabled for version: %0%
Copy
Publish
Publish
@@ -185,6 +187,8 @@
Send To Publish
Sort
Custom
+
Save
+
Save
History (all variants)
@@ -1460,6 +1464,10 @@ To manage your website, simply open the Umbraco backoffice and start adding cont
Rollback to
Select version
View
+
+
Versions
+
Current draft version
+
Current published version
Edit script file
@@ -1615,6 +1623,8 @@ To manage your website, simply open the Umbraco backoffice and start adding cont
There is no domain configured for %0%, please contact an administrator, see
log for more information
+
An error occurred while enabling version cleanup for %0%
+
An error occurred while disabling version cleanup for %0%
Add style
@@ -1891,7 +1901,7 @@ To manage your website, simply open the Umbraco backoffice and start adding cont
Keep all versions newer than days
Keep latest version per day for days
Prevent cleanup
-
NOTE! The cleanup of historically content versions is disabled globally. These settings will not take effect before it is enabled.
+
NOTE! The content version cleanup feature is disabled globally. These settings will not take effect until it is enabled.
Add language
diff --git a/tests/Umbraco.Tests.AcceptanceTest/cypress/integration/Content/content.ts b/tests/Umbraco.Tests.AcceptanceTest/cypress/integration/Content/content.ts
index bc24573b6ab1..2aa409c51c03 100644
--- a/tests/Umbraco.Tests.AcceptanceTest/cypress/integration/Content/content.ts
+++ b/tests/Umbraco.Tests.AcceptanceTest/cypress/integration/Content/content.ts
@@ -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();
diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DocumentVersionRepositoryTest.cs b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DocumentVersionRepositoryTest.cs
index 1649aa2fc6bd..ba5c176ee2f4 100644
--- a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DocumentVersionRepositoryTest.cs
+++ b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DocumentVersionRepositoryTest.cs
@@ -2,6 +2,7 @@
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 @@ public void GetDocumentVersionsEligibleForCleanup_Always_ExcludesActiveVersions(
var contentType = ContentTypeBuilder.CreateSimpleContentType("umbTextpage", "Textpage", defaultTemplateId: template.Id);
ContentTypeService.Save(contentType);
- ContentTypeService.Save(contentType);
var content = ContentBuilder.CreateSimpleContent(contentType);
@@ -130,5 +130,75 @@ public void DeleteVersions_Always_DeletesSpecifiedVersions()
});
}
}
+
+
+ [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);
+ });
+ }
+ }
}
}
diff --git a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Services/ContentVersionCleanupServiceTest.cs b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Services/ContentVersionCleanupServiceTest.cs
index 907c12424aa0..11ff6db9891c 100644
--- a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Services/ContentVersionCleanupServiceTest.cs
+++ b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Services/ContentVersionCleanupServiceTest.cs
@@ -24,7 +24,7 @@ public void PerformContentVersionCleanup_Always_RespectsDeleteRevisionsCancellat
[Frozen] Mock
eventAggregator,
[Frozen] Mock policy,
[Frozen] Mock documentVersionRepository,
- List someHistoricVersions,
+ List someHistoricVersions,
DateTime aDateTime,
ContentVersionService sut)
{
@@ -38,7 +38,7 @@ public void PerformContentVersionCleanup_Always_RespectsDeleteRevisionsCancellat
.Returns(someHistoricVersions);
// # Act
- IReadOnlyCollection report = sut.PerformContentVersionCleanup(aDateTime);
+ IReadOnlyCollection report = sut.PerformContentVersionCleanup(aDateTime);
Assert.Multiple(() =>
{
@@ -53,7 +53,7 @@ public void PerformContentVersionCleanup_Always_FiresDeletedVersionsForEachDelet
[Frozen] Mock eventAggregator,
[Frozen] Mock policy,
[Frozen] Mock documentVersionRepository,
- List someHistoricVersions,
+ List someHistoricVersions,
DateTime aDateTime,
ContentVersionService sut)
{
@@ -78,7 +78,7 @@ public void PerformContentVersionCleanup_Always_ReturnsReportOfDeletedItems(
[Frozen] Mock eventAggregator,
[Frozen] Mock policy,
[Frozen] Mock documentVersionRepository,
- List someHistoricVersions,
+ List someHistoricVersions,
DateTime aDateTime,
ContentVersionService sut)
{
@@ -104,7 +104,7 @@ public void PerformContentVersionCleanup_Always_AdheresToCleanupPolicy(
[Frozen] Mock eventAggregator,
[Frozen] Mock policy,
[Frozen] Mock documentVersionRepository,
- List someHistoricVersions,
+ List someHistoricVersions,
DateTime aDateTime,
ContentVersionService sut)
{
@@ -115,8 +115,8 @@ public void PerformContentVersionCleanup_Always_AdheresToCleanupPolicy(
.Setup(x => x.PublishCancelable(It.IsAny()))
.Returns(false);
- policy.Setup(x => x.Apply(It.IsAny(), It.IsAny>()))
- .Returns>((_, items) => items.Take(1));
+ policy.Setup(x => x.Apply(It.IsAny(), It.IsAny>()))
+ .Returns>((_, items) => items.Take(1));
// # Act
var report = sut.PerformContentVersionCleanup(aDateTime);
@@ -138,7 +138,7 @@ public void PerformContentVersionCleanup_HasVersionsToDelete_CallsDeleteOnReposi
[Frozen] Mock eventAggregator,
[Frozen] Mock policy,
[Frozen] Mock documentVersionRepository,
- List someHistoricVersions,
+ List someHistoricVersions,
DateTime aDateTime,
ContentVersionService sut)
{
@@ -151,8 +151,8 @@ public void PerformContentVersionCleanup_HasVersionsToDelete_CallsDeleteOnReposi
var filteredSet = someHistoricVersions.Take(1);
- policy.Setup(x => x.Apply(It.IsAny(), It.IsAny>()))
- .Returns>((_, items) => filteredSet);
+ policy.Setup(x => x.Apply(It.IsAny(), It.IsAny>()))
+ .Returns>((_, items) => filteredSet);
// # Act
var report = sut.PerformContentVersionCleanup(aDateTime);
diff --git a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Services/DefaultContentVersionCleanupPolicyTest.cs b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Services/DefaultContentVersionCleanupPolicyTest.cs
index db258c5fa150..801c27110d11 100644
--- a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Services/DefaultContentVersionCleanupPolicyTest.cs
+++ b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Services/DefaultContentVersionCleanupPolicyTest.cs
@@ -25,10 +25,10 @@ public void Apply_AllOlderThanKeepSettings_AllVersionsReturned(
{
var versionId = 0;
- var historicItems = new List
+ var historicItems = new List
{
- 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 @@ public void Apply_OverlappingKeepSettings_KeepAllVersionsNewerThanDaysTakesPrior
{
var versionId = 0;
- var historicItems = new List
+ var historicItems = new List
{
- 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 @@ public void Apply_WithinInKeepLatestPerDay_ReturnsSinglePerContentPerDay(
[Frozen] Mock> contentSettings,
DefaultContentVersionCleanupPolicy sut)
{
- var historicItems = new List
+ var historicItems = new List
{
- 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 @@ public void Apply_WithinInKeepLatestPerDay_ReturnsSinglePerContentPerDay(
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 @@ public void Apply_HasOverridePolicy_RespectsPreventCleanup(
[Frozen] Mock> contentSettings,
DefaultContentVersionCleanupPolicy sut)
{
- var historicItems = new List
+ var historicItems = new List
{
- 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 @@ public void Apply_HasOverridePolicy_RespectsKeepAll(
[Frozen] Mock> contentSettings,
DefaultContentVersionCleanupPolicy sut)
{
- var historicItems = new List
+ var historicItems = new List
{
- 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 @@ public void Apply_HasOverridePolicy_RespectsKeepLatest(
[Frozen] Mock> contentSettings,
DefaultContentVersionCleanupPolicy sut)
{
- var historicItems = new List
+ var historicItems = new List
{
- 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 @@ public void Apply_HasOverridePolicy_RespectsKeepLatest(
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));
});
}
}
diff --git a/tests/Umbraco.Tests.UnitTests/Umbraco.Web.BackOffice/Controllers/ContentControllerTests.cs b/tests/Umbraco.Tests.UnitTests/Umbraco.Web.BackOffice/Controllers/ContentControllerTests.cs
index 42b9eb2ddc8d..2d703b8d0fab 100644
--- a/tests/Umbraco.Tests.UnitTests/Umbraco.Web.BackOffice/Controllers/ContentControllerTests.cs
+++ b/tests/Umbraco.Tests.UnitTests/Umbraco.Web.BackOffice/Controllers/ContentControllerTests.cs
@@ -261,7 +261,8 @@ private ContentController CreateContentController(IDomainService domainService)
Mock.Of(),
Mock.Of(),
Mock.Of(),
- Mock.Of()
+ Mock.Of(),
+ Mock.Of()
);
return controller;