Skip to content

Commit

Permalink
Merge branch 'develop' into develop_umb_8
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/DeployCmsData.UmbracoCms.UnitTest/Builders/DocumentTypeTestBuilder.cs
  • Loading branch information
Peter Edney committed Mar 27, 2019
2 parents 6ba0d1a + a170ad4 commit 3402c73
Show file tree
Hide file tree
Showing 14 changed files with 217 additions and 14 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ This project is working but is still under active development so please raise an

## Versions

Version|Umbraco Version|Status
DeployCmsData.UmbracoCms Version|Umbraco Version|Status
--- | --- | ---
7.13.0.3 | 7.13.0|Published to Nuget
7.6.0.5 | 7.6.0|Published to Nuget
7.4.0.3 | 7.4.0|Published to Nuget
8.0.0.0 | 8.0.0|Work in progress
8.0.0.7 | 8.0.0|Published to Nuget
7.13.0.5 | 7.13.0|Published to Nuget
7.6.0.7 | 7.6.0|Published to Nuget
7.4.0.5 | 7.4.0|Published to Nuget


---

Expand Down
4 changes: 3 additions & 1 deletion src/DeployCmsData.IntegrationTest/Tests/IntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ internal class IntegrationTests
[TestCase("MultiNodeTreePicker")]
[TestCase("AllDataTypes")]
[TestCase("UpdateHomePage")]
[TestCase("RemoveAllowedDocType")]
[TestCase("RemoveAllowedDocType")]
[TestCase("GridRowConfiguration")]
[TestCase("DocTypeInheritance")]
public void CallUpgradeScriptApi(string apiMethodName)
{
GetResponse(apiMethodName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal class DocumentTypeTestBuilder
private readonly DocumentTypeBuilder _documentTypeBuilder;
private readonly Mock<IDataTypeService> _dataTypeService;
private IList<ContentTypeSort> _allowedChildNodeTypes;
private IList<PropertyType> _propertyTypes;
private readonly IList<PropertyType> _propertyTypes;

public DocumentTypeTestBuilder(string alias)
{
Expand Down Expand Up @@ -71,14 +71,26 @@ private Mock<IContentType> CreateNewMockContentType(string alias, int id, int pa
return contentType;
}

public DocumentTypeTestBuilder ReturnsExistingContentType(string alias, int id = 0)
public DocumentTypeTestBuilder ReturnsExistingContentType(string alias)
{
return ReturnsExistingContentType(alias, 0);
}

public DocumentTypeTestBuilder ReturnsExistingContentType(string alias, int id)
{
return ReturnsExistingContentType(alias, id, 0);
}

public DocumentTypeTestBuilder ReturnsExistingContentType(string alias, int id, int parentId)
{
var contentType = new Mock<IContentType>();
contentType.SetupAllProperties();
contentType.SetupGet(x => x.Alias).Returns(alias);
contentType.SetupGet(x => x.Id).Returns(id);
contentType.SetupGet(x => x.ParentId).Returns(parentId);

ContentTypeService.Setup(x => x.Get(alias)).Returns(contentType.Object);
ContentTypeService.Setup(x => x.Get(id)).Returns(contentType.Object);

return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,7 @@ public static void AllowAtRoot()
[Test]
public static void DoNotAllowAtRoot()
{
var setup = new DocumentTypeTestBuilder(Alias);

var builder = setup
var builder = new DocumentTypeTestBuilder(Alias)
.SetupNewDocumentType(Alias, Id, ParentFolderId)
.ReturnsFolder(ParentFolderName, ParentFolderLevel, ParentFolderId)
.Build();
Expand All @@ -259,5 +257,22 @@ public static void DoNotAllowAtRoot()

Assert.IsFalse(docType.AllowedAsRoot);
}

[Test]
public static void AddInheritedCompositions()
{
var testBuilder = new DocumentTypeTestBuilder(Alias)
.SetupNewDocumentType(Alias, Id, 444)
.ReturnsExistingContentType("contentType1", 111)
.ReturnsExistingContentType("contentType2", 222, 111)
.ReturnsExistingContentType("contentType3", 333, 222)
.ReturnsExistingContentType("contentType4", 444, 333);

var builder = testBuilder.Build();
var docType = builder.BuildWithParent("contentType4");

testBuilder.ContentType.Verify(x =>
x.AddContentType(It.IsAny<IContentTypeComposition>()), Times.Exactly(4));
}
}
}
16 changes: 16 additions & 0 deletions src/DeployCmsData.UmbracoCms/Builders/DocumentTypeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ private IContentType BuildDocumentType(int parentId)
RemoveFields(documentType);
documentType.AllowedContentTypes = AllowedChildNodeTypes;
AddCompositions(documentType);
AddInheritedCompositions(documentType);

_contentTypeService.Save(documentType);

Expand All @@ -137,6 +138,21 @@ private void AddCompositions(IContentType documentType)
}
}

private void AddInheritedCompositions(IContentType documentType)
{
AddInheritedCompositions(documentType, documentType.ParentId);
}

private void AddInheritedCompositions(IContentType documentType, int parentId)
{
var parent = _contentTypeService.Get(parentId);
if (parent != null && parent.Id > 0)
{
documentType.AddContentType(parent);
AddInheritedCompositions(documentType, parent.ParentId);
}
}

private void SetupTabs(IContentType documentType)
{
foreach (var tab in _tabSortOrder)
Expand Down
2 changes: 1 addition & 1 deletion src/DeployCmsData.UmbracoCms/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("8.0.0.7")]
[assembly: AssemblyVersion("8.0.0.8")]
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@
<Compile Include="UpgradeScripts\BuildWebsite.cs" />
<Compile Include="UpgradeScripts\ClearTheDecks.cs" />
<Compile Include="UpgradeScripts\CreateContent.cs" />
<Compile Include="UpgradeScripts\DocTypeInheritance.cs" />
<Compile Include="UpgradeScripts\GridRowConfiguration.cs" />
<Compile Include="UpgradeScripts\MultiNodeTreePicker.cs" />
<Compile Include="UpgradeScripts\RemoveAllowedDocType.cs" />
<Compile Include="UpgradeScripts\Templates.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using DeployCmsData.Core.Attributes;
using DeployCmsData.Core.Interfaces;
using DeployCmsData.UmbracoCms.Builders;
using System.Linq;
using Validation;

namespace DeployCmsData.UpgradeScripts_7.UpgradeScripts
{
[DoNotAutoRun]
public class DocTypeInheritance : IUpgradeScript
{
public bool RunScript()
{
var builder1 = new DocumentTypeBuilder("websiteRoot");
builder1.AddField("Title")
.Tab("Website Root");
builder1.Update();

var builder2 = new DocumentTypeBuilder("website2");
builder2.AddField("Title 2")
.Tab("Web Site 2");
builder2.BuildWithParent("websiteRoot");

var builder3 = new DocumentTypeBuilder("website3");
builder3.AddField("Title 3")
.Tab("Web Site 3");
builder3.BuildWithParent("website2");

var docType = new DocumentTypeBuilder("inheritedDocTypeTest").
BuildWithParent("website3");

Verify.Operation(docType.CompositionAliases().Count() == 3, "We should have 3 composition aliases");

return true;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using DeployCmsData.Core.Attributes;
using DeployCmsData.Core.Interfaces;
using DeployCmsData.UmbracoCms.Builders;
using System;

namespace DeployCmsData.UpgradeScripts_7.UpgradeScripts
{
[DoNotAutoRun]
public class GridRowConfiguration : IUpgradeScript
{
public bool RunScript()
{
new GridDataTypeBuilder(new Guid("{B0F71D78-745E-4BE5-925E-FA087D44C919}"))
.AddAreaToRow("row 1", 2)
.AddAreaToRow("row 1", 4)
.AddAreaToRow("row 1", 6)
.Build();

new GridDataTypeBuilder(new Guid("{9447F9CF-2112-45CD-933B-6F8F6411EF65}"))
.AddRow("row 1", 2, 4)
.AddAreaToRow("row 1", 6)
.Build();

new GridDataTypeBuilder(new Guid("{D35416BC-58FC-4DB3-B67E-B7111BDA8CAA}"))
.AddAreaToRow("row 1", 2, 10)
.AddAreaToRow("row 1", 4, 20)
.AddAreaToRow("row 1", 6, 30)
.Build();

new GridDataTypeBuilder(new Guid("{4E3F4D54-3900-43A7-B37F-ABDA1802631E}"))
.AddAreaToRow("row 1", 2, 10, "rte", "headline", "image")
.AddAreaToRow("row 1", 4, 20, "image")
.AddAreaToRow("row 1", 6, 30, "headline", "rte")
.Build();

return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@
<Compile Include="UpgradeScripts\BuildWebsite.cs" />
<Compile Include="UpgradeScripts\ClearTheDecks.cs" />
<Compile Include="UpgradeScripts\CreateContent.cs" />
<Compile Include="UpgradeScripts\DocTypeInheritance.cs" />
<Compile Include="UpgradeScripts\GridRowConfiguration.cs" />
<Compile Include="UpgradeScripts\MultiNodeTreePicker.cs" />
<Compile Include="UpgradeScripts\RemoveAllowedDocType.cs" />
<Compile Include="UpgradeScripts\Templates.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using DeployCmsData.Core.Attributes;
using DeployCmsData.Core.Interfaces;
using DeployCmsData.UmbracoCms.Builders;

namespace DeployCmsData.UpgradeScripts_8.UpgradeScripts
{
[DoNotAutoRun]
public class DocTypeInheritance : IUpgradeScript
{
public bool RunScript()
{
var builder1 = new DocumentTypeBuilder("websiteRoot");

builder1.AddField("Title")
.Tab("Website Root");

builder1.Update();

var builder2 = new DocumentTypeBuilder("website2");

builder2.AddField("Title 2")
.Tab("Web Site 2");

builder2.BuildWithParent("websiteRoot");

var builder3 = new DocumentTypeBuilder("website3");

builder3.AddField("Title 3")
.Tab("Web Site 3");

builder3.BuildWithParent("website2");

new DocumentTypeBuilder("inheritedDocTypeTest").
BuildWithParent("website3");

return true;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using DeployCmsData.Core.Attributes;
using DeployCmsData.Core.Interfaces;
using DeployCmsData.UmbracoCms.Builders;
using System;

namespace DeployCmsData.UpgradeScripts._8._0.UpgradeScripts
{
[DoNotAutoRun]
public class GridRowConfiguration : IUpgradeScript
{
public bool RunScript()
{
new GridDataTypeBuilder(new Guid("{B0F71D78-745E-4BE5-925E-FA087D44C919}"))
.AddAreaToRow("row 1", 2)
.AddAreaToRow("row 1", 4)
.AddAreaToRow("row 1", 6)
.Build();

new GridDataTypeBuilder(new Guid("{9447F9CF-2112-45CD-933B-6F8F6411EF65}"))
.AddRow("row 1", 2, 4)
.AddAreaToRow("row 1", 6)
.Build();

new GridDataTypeBuilder(new Guid("{D35416BC-58FC-4DB3-B67E-B7111BDA8CAA}"))
.AddAreaToRow("row 1", 2, 10)
.AddAreaToRow("row 1", 4, 20)
.AddAreaToRow("row 1", 6, 30)
.Build();

new GridDataTypeBuilder(new Guid("{4E3F4D54-3900-43A7-B37F-ABDA1802631E}"))
.AddAreaToRow("row 1", 2, 10, "rte", "headline", "image")
.AddAreaToRow("row 1", 4, 20, "image")
.AddAreaToRow("row 1", 6, 30, "headline", "rte")
.Build();

return true;
}
}
}
2 changes: 1 addition & 1 deletion src/Integration.Web.Umb7.4/Config/ClientDependency.config
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ NOTES:
* Compression/Combination/Minification is not enabled unless debug="false" is specified on the 'compiliation' element in the web.config
* A new version will invalidate both client and server cache and create new persisted files
-->
<clientDependency version="243918105" fileDependencyExtensions=".js,.css" loggerType="Umbraco.Web.UI.CdfLogger, umbraco">
<clientDependency version="1636532227" fileDependencyExtensions=".js,.css" loggerType="Umbraco.Web.UI.CdfLogger, umbraco">

<!--
This section is used for Web Forms only, the enableCompositeFiles="true" is optional and by default is set to true.
Expand Down
1 change: 0 additions & 1 deletion src/Integration.Web.Umb8.0/App_Data/Models/models.hash

This file was deleted.

0 comments on commit 3402c73

Please sign in to comment.