diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs index 93bd9a6408..2dd8287a7c 100644 --- a/src/Umbraco.Core/Services/ContentService.cs +++ b/src/Umbraco.Core/Services/ContentService.cs @@ -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("WHERE nodeId = @Id", new { Id = content.Id }); + foreach (var tag in tags) { - var tags = uow.Database.Fetch("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 }); } } diff --git a/src/Umbraco.Tests/Services/ContentServiceTests.cs b/src/Umbraco.Tests/Services/ContentServiceTests.cs index cf1847ac60..fd5349a0a9 100644 --- a/src/Umbraco.Tests/Services/ContentServiceTests.cs +++ b/src/Umbraco.Tests/Services/ContentServiceTests.cs @@ -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() { }