Merge with 6.0.3

This commit is contained in:
Shannon Deminick
2013-03-22 22:11:56 +06:00
7 changed files with 80 additions and 14 deletions

View File

@@ -41,11 +41,11 @@ namespace Umbraco.Core.Persistence.Repositories
.RightJoin<PropertyTypeDto>()
.On<PropertyTypeGroupDto, PropertyTypeDto>(left => left.Id, right => right.PropertyTypeGroupId)
.InnerJoin<DataTypeDto>()
.On<PropertyTypeDto, DataTypeDto>(left => left.DataTypeId, right => right.DataTypeId)
.OrderBy<PropertyTypeDto>(x => x.PropertyTypeGroupId);
.On<PropertyTypeDto, DataTypeDto>(left => left.DataTypeId, right => right.DataTypeId);
var translator = new SqlTranslator<PropertyType>(sqlClause, query);
var sql = translator.Translate();
var sql = translator.Translate()
.OrderBy<PropertyTypeDto>(x => x.PropertyTypeGroupId);
var dtos = Database.Fetch<PropertyTypeGroupDto, PropertyTypeDto, DataTypeDto, PropertyTypeGroupDto>(new GroupPropertyTypeRelator().Map, sql);

View File

@@ -246,7 +246,7 @@ namespace Umbraco.Core.Services
foreach (var group in contentType.PropertyGroups)
{
var types = @group.PropertyTypes.Where(x => x.DataTypeDefinitionId == dataTypeDefinition.Id);
var types = @group.PropertyTypes.Where(x => x.DataTypeDefinitionId == dataTypeDefinition.Id).ToList();
foreach (var propertyType in types)
{
@group.PropertyTypes.Remove(propertyType);

View File

@@ -3,17 +3,12 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Rdbms;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Repositories;
using Umbraco.Core.Persistence.UnitOfWork;
using Umbraco.Core.Services;
using Umbraco.Tests.TestHelpers;
using Umbraco.Tests.TestHelpers.Entities;
using umbraco.editorControls.tinyMCE3;
using umbraco.interfaces;
namespace Umbraco.Tests.Services
{

View File

@@ -0,0 +1,66 @@
using System;
using System.Linq;
using NUnit.Framework;
using Umbraco.Core.Models;
namespace Umbraco.Tests.Services
{
/// <summary>
/// Tests covering the DataTypeService
/// </summary>
[TestFixture, RequiresSTA]
public class DataTypeServiceTests : BaseServiceTest
{
[SetUp]
public override void Initialize()
{
base.Initialize();
}
[TearDown]
public override void TearDown()
{
base.TearDown();
}
[Test]
public void DataTypeService_Can_Persist_New_DataTypeDefinition()
{
// Arrange
var dataTypeService = ServiceContext.DataTypeService;
var textfieldId = new Guid("ec15c1e5-9d90-422a-aa52-4f7622c63bea");
// Act
var dataTypeDefinition = new DataTypeDefinition(-1, textfieldId) { Name = "Testing Textfield", DatabaseType = DataTypeDatabaseType.Ntext };
dataTypeService.Save(dataTypeDefinition);
// Assert
Assert.That(dataTypeDefinition, Is.Not.Null);
Assert.That(dataTypeDefinition.HasIdentity, Is.True);
}
[Test]
public void DataTypeService_Can_Delete_Textfield_DataType_And_Clear_Usages()
{
// Arrange
var dataTypeService = ServiceContext.DataTypeService;
var textfieldId = new Guid("ec15c1e5-9d90-422a-aa52-4f7622c63bea");
var dataTypeDefinitions = dataTypeService.GetDataTypeDefinitionByControlId(textfieldId);
// Act
var definition = dataTypeDefinitions.First();
var definitionId = definition.Id;
dataTypeService.Delete(definition);
var deletedDefinition = dataTypeService.GetDataTypeDefinitionById(definitionId);
// Assert
Assert.That(deletedDefinition, Is.Null);
//Further assertions against the ContentType that contains PropertyTypes based on the TextField
var contentType = ServiceContext.ContentTypeService.GetContentType(1045);
Assert.That(contentType.Alias, Is.EqualTo("umbTextpage"));
Assert.That(contentType.PropertyTypes.Count(), Is.EqualTo(1));
}
}
}

View File

@@ -105,9 +105,9 @@ namespace Umbraco.Tests.TestHelpers.Entities
contentType.Trashed = false;
var contentCollection = new PropertyTypeCollection();
contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "title", Name = "Title", Description = "", HelpText = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 });
contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "bodyText", Name = "Body Text", Description = "", HelpText = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -87 });
contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "author", Name = "Author", Description = "Name of the author", HelpText = "", Mandatory = false, SortOrder = 3, DataTypeDefinitionId = -88 });
contentCollection.Add(new PropertyType(new Guid("ec15c1e5-9d90-422a-aa52-4f7622c63bea"), DataTypeDatabaseType.Ntext) { Alias = "title", Name = "Title", Description = "", HelpText = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 });
contentCollection.Add(new PropertyType(new Guid("5E9B75AE-FACE-41c8-B47E-5F4B0FD82F83"), DataTypeDatabaseType.Ntext) { Alias = "bodyText", Name = "Body Text", Description = "", HelpText = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -87 });
contentCollection.Add(new PropertyType(new Guid("ec15c1e5-9d90-422a-aa52-4f7622c63bea"), DataTypeDatabaseType.Ntext) { Alias = "author", Name = "Author", Description = "Name of the author", HelpText = "", Mandatory = false, SortOrder = 3, DataTypeDefinitionId = -88 });
contentType.PropertyGroups.Add(new PropertyGroup(contentCollection) { Name = "Content", SortOrder = 1 });

View File

@@ -294,6 +294,7 @@
<Compile Include="Services\ContentServicePerformanceTest.cs" />
<Compile Include="Services\ContentServiceTests.cs" />
<Compile Include="Services\ContentTypeServiceTests.cs" />
<Compile Include="Services\DataTypeServiceTests.cs" />
<Compile Include="Services\Importing\PackageImportTests.cs" />
<Compile Include="Services\Importing\ImportResources.Designer.cs">
<AutoGen>True</AutoGen>

View File

@@ -7,7 +7,6 @@ using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Persistence.Caching;
using umbraco.BusinessLogic;
using umbraco.cms.businesslogic.propertytype;
using umbraco.DataLayer;
using System.Collections.Generic;
using Umbraco.Core;
@@ -551,7 +550,12 @@ namespace umbraco.cms.businesslogic.web
protected virtual void FireAfterSave(SaveEventArgs e)
{
if (AfterSave != null)
AfterSave(this, e);
{
var updated = this._contentType == null
? new DocumentType(this.Id)
: new DocumentType(this._contentType);
AfterSave(updated, e);
}
}
/// <summary>