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:
Shannon
2013-11-15 17:54:01 +11:00
parent 2784e2a22d
commit 259d8e03db
2 changed files with 25 additions and 7 deletions

View File

@@ -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 });
}
}

View File

@@ -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()
{ }