Fixes: U4-4368 Cannot insert the value NULL into column 'name' when creating new relation type from API
This commit is contained in:
@@ -21,9 +21,18 @@ namespace Umbraco.Core.Models
|
||||
|
||||
public RelationType(Guid childObjectType, Guid parentObjectType, string @alias)
|
||||
{
|
||||
Mandate.ParameterNotNullOrEmpty(@alias, "alias");
|
||||
_childObjectType = childObjectType;
|
||||
_parentObjectType = parentObjectType;
|
||||
_alias = alias;
|
||||
Name = _alias;
|
||||
}
|
||||
|
||||
public RelationType(Guid childObjectType, Guid parentObjectType, string @alias, string name)
|
||||
:this(childObjectType, parentObjectType, @alias)
|
||||
{
|
||||
Mandate.ParameterNotNullOrEmpty(name, "name");
|
||||
Name = name;
|
||||
}
|
||||
|
||||
private static readonly PropertyInfo NameSelector = ExpressionHelper.GetPropertyInfo<RelationType, string>(x => x.Name);
|
||||
|
||||
@@ -14,7 +14,7 @@ using Umbraco.Tests.TestHelpers.Entities;
|
||||
|
||||
namespace Umbraco.Tests.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// Tests covering all methods in the ContentService class.
|
||||
/// This is more of an integration test as it involves multiple layers
|
||||
/// as well as configuration.
|
||||
|
||||
34
src/Umbraco.Tests/Services/RelationServiceTests.cs
Normal file
34
src/Umbraco.Tests/Services/RelationServiceTests.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
|
||||
namespace Umbraco.Tests.Services
|
||||
{
|
||||
[TestFixture, RequiresSTA]
|
||||
public class RelationServiceTests : BaseServiceTest
|
||||
{
|
||||
[SetUp]
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public override void TearDown()
|
||||
{
|
||||
base.TearDown();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Create_RelationType_Without_Name()
|
||||
{
|
||||
var rs = ServiceContext.RelationService;
|
||||
var rt = new RelationType(new Guid(Constants.ObjectTypes.Document), new Guid(Constants.ObjectTypes.Document), "repeatedEventOccurence");
|
||||
|
||||
Assert.DoesNotThrow(() => rs.Save(rt));
|
||||
|
||||
Assert.AreEqual(rt.Name, "repeatedEventOccurence");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -234,6 +234,7 @@
|
||||
<Compile Include="Services\MemberTypeServiceTests.cs" />
|
||||
<Compile Include="Services\PackagingServiceTests.cs" />
|
||||
<Compile Include="Services\PerformanceTests.cs" />
|
||||
<Compile Include="Services\RelationServiceTests.cs" />
|
||||
<Compile Include="Services\UserServiceTests.cs" />
|
||||
<Compile Include="TestHelpers\BaseSeleniumTest.cs" />
|
||||
<Compile Include="Integration\InstallPackage.cs" />
|
||||
|
||||
Reference in New Issue
Block a user