Fixes #U4-2068 and #U4-2125
Creating test for verifying path is correctly updated when moving items to the recycle bin.
This commit is contained in:
@@ -683,7 +683,7 @@ namespace Umbraco.Core.Services
|
||||
}
|
||||
|
||||
//Unpublish descendents of the content item that is being moved to trash
|
||||
var descendants = GetDescendants(content).ToList();
|
||||
var descendants = GetDescendants(content).OrderBy(x => x.Level).ToList();
|
||||
foreach (var descendant in descendants)
|
||||
{
|
||||
UnPublish(descendant, userId);
|
||||
@@ -819,8 +819,8 @@ namespace Umbraco.Core.Services
|
||||
var uow = _uowProvider.GetUnitOfWork();
|
||||
using (var repository = _repositoryFactory.CreateContentRepository(uow))
|
||||
{
|
||||
var query = Query<IContent>.Builder.Where(x => x.Path.Contains("-20"));
|
||||
var contents = repository.GetByQuery(query).OrderByDescending(x => x.ParentId);
|
||||
var query = Query<IContent>.Builder.Where(x => x.Trashed == true);
|
||||
var contents = repository.GetByQuery(query).OrderByDescending(x => x.Level);
|
||||
|
||||
foreach (var content in contents)
|
||||
{
|
||||
|
||||
@@ -393,7 +393,7 @@ namespace Umbraco.Core.Services
|
||||
return;
|
||||
|
||||
//Find Descendants, which will be moved to the recycle bin along with the parent/grandparent.
|
||||
var descendants = GetDescendants(media).ToList();
|
||||
var descendants = GetDescendants(media).OrderBy(x => x.Level).ToList();
|
||||
|
||||
var uow = _uowProvider.GetUnitOfWork();
|
||||
using (var repository = _repositoryFactory.CreateMediaRepository(uow))
|
||||
@@ -426,8 +426,8 @@ namespace Umbraco.Core.Services
|
||||
var uow = _uowProvider.GetUnitOfWork();
|
||||
using (var repository = _repositoryFactory.CreateMediaRepository(uow))
|
||||
{
|
||||
var query = Query<IMedia>.Builder.Where(x => x.Path.Contains("-21"));
|
||||
var contents = repository.GetByQuery(query).OrderByDescending(x => x.ParentId);
|
||||
var query = Query<IMedia>.Builder.Where(x => x.Trashed == true);
|
||||
var contents = repository.GetByQuery(query).OrderByDescending(x => x.Level);
|
||||
|
||||
foreach (var content in contents)
|
||||
{
|
||||
|
||||
@@ -567,6 +567,34 @@ namespace Umbraco.Tests.Services
|
||||
Assert.That(content.Trashed, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Move_Content_Structure_To_RecycleBin_And_Empty_RecycleBin()
|
||||
{
|
||||
// Arrange
|
||||
var contentService = ServiceContext.ContentService;
|
||||
var contentType = ServiceContext.ContentTypeService.GetContentType("umbTextpage");
|
||||
Content subsubpage = MockedContent.CreateSimpleContent(contentType, "Text Page 3", 1047);
|
||||
contentService.Save(subsubpage, 0);
|
||||
|
||||
var content = contentService.GetById(1046);
|
||||
|
||||
// Act
|
||||
contentService.MoveToRecycleBin(content, 0);
|
||||
var descendants = contentService.GetDescendants(content);
|
||||
|
||||
// Assert
|
||||
Assert.That(content.ParentId, Is.EqualTo(-20));
|
||||
Assert.That(content.Trashed, Is.True);
|
||||
Assert.That(descendants.Count(), Is.EqualTo(3));
|
||||
Assert.That(descendants.Any(x => x.Path.Contains("-20") == false), Is.False);
|
||||
|
||||
//Empty Recycle Bin
|
||||
contentService.EmptyRecycleBin();
|
||||
var trashed = contentService.GetContentInRecycleBin();
|
||||
|
||||
Assert.That(trashed.Any(), Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Empty_RecycleBin()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user