Fixes: U4-4466 6.2-beta - Creating Member Type without Alias results in no viewable Member Types in back office

This commit is contained in:
Shannon
2014-03-20 09:52:31 +11:00
parent ff5dadde53
commit 84dd7dc61a
3 changed files with 23 additions and 3 deletions

View File

@@ -44,7 +44,9 @@ namespace Umbraco.Core.Models
SetPropertyValueAndDetectChanges(o =>
{
_alias = value == "_umbracoSystemDefaultProtectType" ? value : value.ToSafeAlias();
_alias = value == "_umbracoSystemDefaultProtectType"
? value
: (value == null ? string.Empty : value.ToSafeAlias() );
return _alias;
}, _alias, AliasSelector);
}

View File

@@ -166,8 +166,10 @@ namespace Umbraco.Core.Persistence.Repositories
protected override void PersistNewItem(IMemberType entity)
{
((MemberType)entity).AddingEntity();
ValidateAlias(entity);
((MemberType)entity).AddingEntity();
//By Convention we add 9 stnd PropertyTypes to an Umbraco MemberType
entity.AddPropertyGroup(Constants.Conventions.Member.StandardPropertiesGroupName);
var standardPropertyTypes = Constants.Conventions.Member.GetStandardPropertyTypeStubs();

View File

@@ -1,4 +1,5 @@
using System.Linq;
using System;
using System.Linq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Models;
@@ -70,6 +71,21 @@ namespace Umbraco.Tests.Persistence.Repositories
}
}
[Test]
public void Cannot_Persist_Member_Type_Without_Alias()
{
var provider = new PetaPocoUnitOfWorkProvider();
var unitOfWork = provider.GetUnitOfWork();
using (var repository = CreateRepository(unitOfWork))
{
var memberType = MockedContentTypes.CreateSimpleMemberType();
memberType.Alias = null;
repository.AddOrUpdate(memberType);
Assert.Throws<InvalidOperationException>(unitOfWork.Commit);
}
}
[Test]
public void Can_Get_All_Member_Types()
{