DataType refactoring - all tests green
This commit is contained in:
@@ -24,11 +24,11 @@ namespace Umbraco.Core.Models
|
||||
{
|
||||
if (property == null) throw new ArgumentNullException(nameof(property));
|
||||
|
||||
var editor = PropertyEditors[property.Alias];
|
||||
var editor = PropertyEditors[property.PropertyType.PropertyEditorAlias];
|
||||
var tagAttribute = editor.GetTagAttribute();
|
||||
if (tagAttribute == null) return null;
|
||||
|
||||
var configurationObject = DataTypeService.GetDataType(property.PropertyType.DataTypeId);
|
||||
var configurationObject = DataTypeService.GetDataType(property.PropertyType.DataTypeId).Configuration;
|
||||
var configuration = ConfigurationEditor.ConfigurationAs<TagConfiguration>(configurationObject);
|
||||
|
||||
if (configuration.Delimiter == default)
|
||||
|
||||
@@ -417,7 +417,10 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
var editorAlias = propertyTypeDto.DataTypeDto.EditorAlias;
|
||||
var editorAttribute = PropertyEditors[editorAlias].GetTagAttribute();
|
||||
if (editorAttribute == null) continue;
|
||||
var tagConfiguration = ConfigurationEditor.ConfigurationAs<TagConfiguration>(propertyTypeDto.DataTypeDto.Configuration);
|
||||
var tagConfigurationSource = propertyTypeDto.DataTypeDto.Configuration;
|
||||
var tagConfiguration = string.IsNullOrWhiteSpace(tagConfigurationSource)
|
||||
? new TagConfiguration()
|
||||
: JsonConvert.DeserializeObject<TagConfiguration>(tagConfigurationSource);
|
||||
if (tagConfiguration.Delimiter == default) tagConfiguration.Delimiter = editorAttribute.Delimiter;
|
||||
tagEditors[editorAlias] = tagConfiguration;
|
||||
}
|
||||
|
||||
@@ -991,6 +991,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
if (result.Success == false)
|
||||
{
|
||||
scope.Events.Dispatch(TreeChanged, this, new TreeChange<IContent>(content, changeType).ToEventArgs());
|
||||
scope.Complete(); // compete the save
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
@@ -18,7 +19,6 @@ namespace Umbraco.Tests.Services
|
||||
public class TagServiceTests : TestWithSomeContentBase
|
||||
{
|
||||
[Test]
|
||||
[Explicit("Fails, tags API is not consistent.")]
|
||||
public void TagApiConsistencyTest()
|
||||
{
|
||||
var contentService = ServiceContext.ContentService;
|
||||
@@ -34,12 +34,24 @@ namespace Umbraco.Tests.Services
|
||||
|
||||
IContent content1 = MockedContent.CreateSimpleContent(contentType, "Tagged content 1", -1);
|
||||
content1.AssignTags("tags", new[] { "cow", "pig", "goat" });
|
||||
content1.PublishValues();
|
||||
contentService.SaveAndPublish(content1);
|
||||
|
||||
// change
|
||||
content1.AssignTags("tags", new[] { "elephant" }, true);
|
||||
content1.RemoveTags("tags", new[] { "cow" });
|
||||
content1.PublishValues();
|
||||
contentService.SaveAndPublish(content1);
|
||||
|
||||
// more changes
|
||||
content1.AssignTags("tags", new[] { "mouse" }, true);
|
||||
content1.PublishValues();
|
||||
contentService.SaveAndPublish(content1);
|
||||
content1.RemoveTags("tags", new[] { "mouse" });
|
||||
content1.PublishValues();
|
||||
contentService.SaveAndPublish(content1);
|
||||
|
||||
// get it back
|
||||
content1 = contentService.GetById(content1.Id);
|
||||
var tagsValue = content1.GetValue("tags").ToString();
|
||||
var tagsValues = tagsValue.Split(',');
|
||||
@@ -66,9 +78,9 @@ namespace Umbraco.Tests.Services
|
||||
var tagService = ServiceContext.TagService;
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType("umbMandatory", "Mandatory Doc Type", true);
|
||||
contentType.PropertyGroups.First().PropertyTypes.Add(
|
||||
new PropertyType("test", ValueStorageType.Ntext, "tags")
|
||||
new PropertyType(Constants.PropertyEditors.Aliases.Tags, ValueStorageType.Ntext, "tags")
|
||||
{
|
||||
DataTypeId = 1041
|
||||
DataTypeId = Constants.DataTypes.Tags
|
||||
});
|
||||
contentTypeService.Save(contentType);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user