Skip to content

Commit

Permalink
Revert "Preserve sort order when copying content"
Browse files Browse the repository at this point in the history
This reverts commit 47dc631.
  • Loading branch information
nul800sebastiaan committed Aug 31, 2020
1 parent ed59b22 commit 7030371
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 28 deletions.
2 changes: 1 addition & 1 deletion src/Umbraco.Core/Services/Implement/ContentService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2200,7 +2200,7 @@ public IContent Copy(IContent content, int parentId, bool relateToOriginal, bool
var total = long.MaxValue;
while (page * pageSize < total)
{
var descendants = GetPagedDescendants(content.Id, page++, pageSize, out total, ordering: Ordering.By("sortOrder"));
var descendants = GetPagedDescendants(content.Id, page++, pageSize, out total);
foreach (var descendant in descendants)
{
// if parent has not been copied, skip, else gets its copy id
Expand Down
27 changes: 0 additions & 27 deletions src/Umbraco.Tests/Services/ContentServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1959,33 +1959,6 @@ public void Can_Copy_Recursive()
Assert.AreNotEqual(childCopy.Key, child.Key);
}


[Test]
public void Copy_Recursive_Preserves_Sort_Order()
{
// Arrange
var contentService = ServiceContext.ContentService;
var temp = contentService.GetById(NodeDto.NodeIdSeed + 2);
Assert.AreEqual("Home", temp.Name);
Assert.AreEqual(2, contentService.CountChildren(temp.Id));
var reversedChildren = contentService.GetPagedChildren(temp.Id, 0, 10, out var total1).Reverse().ToArray();
contentService.Sort(reversedChildren);

// Act
var copy = contentService.Copy(temp, temp.ParentId, false, true, Constants.Security.SuperUserId);
var content = contentService.GetById(NodeDto.NodeIdSeed + 2);

// Assert
Assert.That(copy, Is.Not.Null);
Assert.That(copy.Id, Is.Not.EqualTo(content.Id));
Assert.AreNotSame(content, copy);
Assert.AreEqual(2, contentService.CountChildren(copy.Id));

var copiedChildren = contentService.GetPagedChildren(copy.Id, 0, 10, out var total2).OrderBy(c => c.SortOrder).ToArray();
Assert.AreEqual(reversedChildren.First().Name, copiedChildren.First().Name);
Assert.AreEqual(reversedChildren.Last().Name, copiedChildren.Last().Name);
}

[Test]
public void Can_Copy_NonRecursive()
{
Expand Down

0 comments on commit 7030371

Please sign in to comment.