U4-9326 Removing a master template from a Template does not update the Template's path correctly
This commit is contained in:
@@ -241,7 +241,12 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
{
|
||||
entity.Path = string.Concat(parent.Path, ",", entity.Id);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
//this means that the master template has been removed, so we need to reset the template's
|
||||
//path to be at the root
|
||||
entity.Path = string.Concat("-1,", entity.Id);
|
||||
}
|
||||
}
|
||||
|
||||
//Get TemplateDto from db to get the Primary key of the entity
|
||||
|
||||
@@ -707,6 +707,35 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Path_Is_Set_Correctly_On_Update_With_Master_Template_Removal()
|
||||
{
|
||||
// Arrange
|
||||
var provider = new PetaPocoUnitOfWorkProvider(Logger);
|
||||
var unitOfWork = provider.GetUnitOfWork();
|
||||
using (var repository = CreateRepository(unitOfWork))
|
||||
{
|
||||
var parent = new Template("parent", "parent");
|
||||
var child1 = new Template("child1", "child1");
|
||||
|
||||
child1.MasterTemplateAlias = parent.Alias;
|
||||
child1.MasterTemplateId = new Lazy<int>(() => parent.Id);
|
||||
|
||||
repository.AddOrUpdate(parent);
|
||||
repository.AddOrUpdate(child1);
|
||||
unitOfWork.Commit();
|
||||
|
||||
//Act
|
||||
child1.SetMasterTemplate(null);
|
||||
repository.AddOrUpdate(child1);
|
||||
unitOfWork.Commit();
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual(string.Format("-1,{0}", child1.Id), child1.Path);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[TearDown]
|
||||
public override void TearDown()
|
||||
|
||||
Reference in New Issue
Block a user