public void GetDocumentVersionsEligibleForCleanup_Always_ExcludesActiveVersions() { var contentType = MockedContentTypes.CreateSimpleContentType("umbTextpage", "Textpage"); ServiceContext.FileService.SaveTemplate(contentType.DefaultTemplate); ServiceContext.ContentTypeService.Save(contentType); var content = MockedContent.CreateSimpleContent(contentType); ServiceContext.ContentService.SaveAndPublish(content); // At this point content has 2 versions, a draft version and a published version. ServiceContext.ContentService.SaveAndPublish(content); // At this point content has 3 versions, a historic version, a draft version and a published version. var scopeProvider = TestObjects.GetScopeProvider(Logger); using (scopeProvider.CreateScope()) { var sut = new DocumentVersionRepository((IScopeAccessor)scopeProvider); var results = sut.GetDocumentVersionsEligibleForCleanup(); Assert.Multiple(() => { Assert.AreEqual(1, results.Count); Assert.AreEqual(1, results.First().VersionId); }); } }
public void GetDocumentVersionsEligibleForCleanup_Always_ExcludesActiveVersions() { Template template = TemplateBuilder.CreateTextPageTemplate(); FileService.SaveTemplate(template); var contentType = ContentTypeBuilder.CreateSimpleContentType("umbTextpage", "Textpage", defaultTemplateId: template.Id); ContentTypeService.Save(contentType); ContentTypeService.Save(contentType); var content = ContentBuilder.CreateSimpleContent(contentType); ContentService.SaveAndPublish(content); // At this point content has 2 versions, a draft version and a published version. ContentService.SaveAndPublish(content); // At this point content has 3 versions, a historic version, a draft version and a published version. using (ScopeProvider.CreateScope()) { var sut = new DocumentVersionRepository(ScopeAccessor); var results = sut.GetDocumentVersionsEligibleForCleanup(); Assert.Multiple(() => { Assert.AreEqual(1, results.Count); Assert.AreEqual(1, results.First().VersionId); }); } }
public void GetDocumentVersionsEligibleForCleanup_Always_ExcludesPinnedVersions() { var template = TemplateBuilder.CreateTextPageTemplate(); FileService.SaveTemplate(template); var contentType = ContentTypeBuilder.CreateSimpleContentType("umbTextpage", "Textpage", defaultTemplateId: template.Id); ContentTypeService.Save(contentType); ContentTypeService.Save(contentType); var content = ContentBuilder.CreateSimpleContent(contentType); ContentService.SaveAndPublish(content); // At this point content has 2 versions, a draft version and a published version. ContentService.SaveAndPublish(content); ContentService.SaveAndPublish(content); ContentService.SaveAndPublish(content); // At this point content has 5 versions, 3 historic versions, a draft version and a published version. var allVersions = ContentService.GetVersions(content.Id); Debug.Assert(allVersions.Count() == 5); // Sanity check using (var scope = ScopeProvider.CreateScope()) { ScopeAccessor.AmbientScope.Database.Update <ContentVersionDto>("set preventCleanup = 1 where id in (1,3)"); var sut = new DocumentVersionRepository(ScopeAccessor); var results = sut.GetDocumentVersionsEligibleForCleanup(); Assert.Multiple(() => { Assert.AreEqual(1, results.Count); // We pinned 1 & 3 // 4 is current // 5 is published // So all that is left is 2 Assert.AreEqual(2, results.First().VersionId); }); } }