completes: U4-3300 Need to test content service copy API with tags - since there's 'special' code in there to handle it that's not been tested with the new changes - with test
This commit is contained in:
@@ -1170,14 +1170,11 @@ namespace Umbraco.Core.Services
|
||||
}
|
||||
}
|
||||
|
||||
//Special case for the Tags DataType
|
||||
if (content.Properties.Any(x => x.PropertyType.PropertyEditorAlias == Constants.PropertyEditors.TagsAlias))
|
||||
//Special case for the associated tags
|
||||
var tags = uow.Database.Fetch<TagRelationshipDto>("WHERE nodeId = @Id", new { Id = content.Id });
|
||||
foreach (var tag in tags)
|
||||
{
|
||||
var tags = uow.Database.Fetch<TagRelationshipDto>("WHERE nodeId = @Id", new { Id = content.Id });
|
||||
foreach (var tag in tags)
|
||||
{
|
||||
uow.Database.Insert(new TagRelationshipDto { NodeId = copy.Id, TagId = tag.TagId });
|
||||
}
|
||||
uow.Database.Insert(new TagRelationshipDto { NodeId = copy.Id, TagId = tag.TagId, PropertyTypeId = tag.PropertyTypeId });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -865,6 +865,27 @@ namespace Umbraco.Tests.Services
|
||||
//Assert.AreNotEqual(content.Name, copy.Name);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Copy_Content_With_Tags()
|
||||
{
|
||||
// Arrange
|
||||
var contentService = ServiceContext.ContentService;
|
||||
var contentType = ServiceContext.ContentTypeService.GetContentType("umbTextpage");
|
||||
var temp = MockedContent.CreateSimpleContent(contentType, "Simple Text Page", -1);
|
||||
var prop = temp.Properties.First();
|
||||
temp.SetTags(prop.Alias, new[] {"hello", "world"}, true);
|
||||
var status = contentService.PublishWithStatus(temp);
|
||||
|
||||
// Act
|
||||
var copy = contentService.Copy(temp, temp.ParentId, false, 0);
|
||||
|
||||
// Assert
|
||||
var copiedTags = ServiceContext.TagService.GetTagsForEntity(copy.Id).ToArray();
|
||||
Assert.AreEqual(2, copiedTags.Count());
|
||||
Assert.AreEqual("hello", copiedTags[0].Text);
|
||||
Assert.AreEqual("world", copiedTags[1].Text);
|
||||
}
|
||||
|
||||
[Test, NUnit.Framework.Ignore]
|
||||
public void Can_Send_To_Publication()
|
||||
{ }
|
||||
|
||||
Reference in New Issue
Block a user