Merge branch 'v8/8.8' into v8/8.9
This commit is contained in:
@@ -448,8 +448,14 @@ AND umbracoNode.id <> @id",
|
||||
// The composed property is only considered segment variant when the base content type is also segment variant.
|
||||
// Example: Culture variant content type with a Culture+Segment variant property type will become ContentVariation.Culture
|
||||
var target = newContentTypeVariation & composedPropertyType.Variations;
|
||||
// Determine the previous variation
|
||||
// We have to compare with the old content type variation because the composed property might already have changed
|
||||
// Example: A property with variations in an element type with variations is used in a document without
|
||||
// when you enable variations the property has already enabled variations from the element type,
|
||||
// but it's still a change from nothing because the document did not have variations, but it does now.
|
||||
var from = oldContentTypeVariation & composedPropertyType.Variations;
|
||||
|
||||
propertyTypeVariationChanges[composedPropertyType.Id] = (composedPropertyType.Variations, target);
|
||||
propertyTypeVariationChanges[composedPropertyType.Id] = (from, target);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.TestHelpers.Entities;
|
||||
using Umbraco.Tests.Testing;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Content = Umbraco.Core.Models.Content;
|
||||
|
||||
namespace Umbraco.Tests.Persistence.Repositories
|
||||
{
|
||||
@@ -997,6 +998,88 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Update_Variation_Of_Element_Type_Property()
|
||||
{
|
||||
var provider = TestObjects.GetScopeProvider(Logger);
|
||||
using (var scope = provider.CreateScope())
|
||||
{
|
||||
ContentTypeRepository repository;
|
||||
var contentRepository = CreateRepository((IScopeAccessor) provider, out repository);
|
||||
|
||||
// Create elementType
|
||||
var elementType = new ContentType(-1)
|
||||
{
|
||||
Alias = "elementType",
|
||||
Name = "Element type",
|
||||
Description = "Element type to use as compositions",
|
||||
Icon = ".sprTreeDoc3",
|
||||
Thumbnail = "doc.png",
|
||||
SortOrder = 1,
|
||||
CreatorId = 0,
|
||||
Trashed = false,
|
||||
IsElement = true,
|
||||
Variations = ContentVariation.Nothing
|
||||
};
|
||||
|
||||
var contentCollection = new PropertyTypeCollection(true);
|
||||
contentCollection.Add(new PropertyType("test", ValueStorageType.Ntext)
|
||||
{
|
||||
Alias = "title",
|
||||
Name = "Title",
|
||||
Description = "",
|
||||
Mandatory = false,
|
||||
SortOrder = 1,
|
||||
DataTypeId = Constants.DataTypes.Textbox,
|
||||
LabelOnTop = true,
|
||||
Variations = ContentVariation.Nothing
|
||||
});
|
||||
elementType.PropertyGroups.Add(new PropertyGroup(contentCollection) {Name = "Content", SortOrder = 1});
|
||||
elementType.ResetDirtyProperties(false);
|
||||
elementType.SetDefaultTemplate(new Template("ElementType", "elementType"));
|
||||
repository.Save(elementType);
|
||||
|
||||
// Create the basic "home" doc type that uses element type as comp
|
||||
var docType = new ContentType(-1)
|
||||
{
|
||||
Alias = "home",
|
||||
Name = "Home",
|
||||
Description = "Home containing elementType",
|
||||
Icon = ".sprTreeDoc3",
|
||||
Thumbnail = "doc.png",
|
||||
SortOrder = 1,
|
||||
CreatorId = 0,
|
||||
Trashed = false,
|
||||
Variations = ContentVariation.Nothing
|
||||
};
|
||||
var comp = new List<IContentTypeComposition>();
|
||||
comp.Add(elementType);
|
||||
docType.ContentTypeComposition = comp;
|
||||
repository.Save(docType);
|
||||
|
||||
// Create "home" content
|
||||
var content = new Content("Home", -1, docType){Level = 1, SortOrder = 1, CreatorId = 0, WriterId = 0};
|
||||
object obj = new {title = "test title"};
|
||||
content.PropertyValues(obj);
|
||||
content.ResetDirtyProperties(false);
|
||||
contentRepository.Save(content);
|
||||
|
||||
// Update variation on element type
|
||||
elementType.Variations = ContentVariation.Culture;
|
||||
elementType.PropertyTypes.First().Variations = ContentVariation.Culture;
|
||||
repository.Save(elementType);
|
||||
|
||||
// Update variation on doc type
|
||||
docType.Variations = ContentVariation.Culture;
|
||||
repository.Save(docType);
|
||||
|
||||
// Re fetch renewedContent and make sure that the culture has been set.
|
||||
var renewedContent = ServiceContext.ContentService.GetById(content.Id);
|
||||
var hasCulture = renewedContent.Properties["title"].Values.First().Culture != null;
|
||||
Assert.That(hasCulture, Is.True);
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateTestData()
|
||||
{
|
||||
//Create and Save ContentType "umbTextpage" -> (NodeDto.NodeIdSeed)
|
||||
|
||||
Reference in New Issue
Block a user