Fixing List specflow tests

--HG--
branch : autoroute
This commit is contained in:
Sebastien Ros
2012-02-07 16:04:57 -08:00
parent 74a933fb4e
commit b923915332
6 changed files with 24 additions and 137 deletions

View File

@@ -1,8 +1,8 @@
6766f8961c16fce20dd9f1cff2abbabc1d8913f3 src/Orchard.Web/Modules/Orchard.Autoroute
5e57314d12cb06337920ca140f80477a6e3f6d92 src/Orchard.Web/Modules/Orchard.Autoroute
c54cb640d6bc14c51b9fb9bd78231bb0facec067 src/Orchard.Web/Modules/Orchard.Forms
204bdef384f41bb5e463bed6b98a056945a7d839 src/Orchard.Web/Modules/Orchard.Rules
ce578373f907c0a55fd91229a344f0755f290174 src/Orchard.Web/Modules/Orchard.TaskLease
29a8e4e60bed53a91e109f85879ffd0a6df6ec2c src/Orchard.Web/Modules/Orchard.Tokens
c6a4d1a5603381cbfc1d694e9525f42fd5ecdb79 src/Orchard.Web/Modules/Orchard.Tokens
8375c8c10297aa9b66f792354bed25268184cd08 src/orchard.web/modules/Orchard.Alias
114e75928872042f092b0cc7cafa1a58c208d8ae src/orchard.web/modules/Orchard.Fields
913ced6d47a208394f8149d1573c2f2d61240d24 src/orchard.web/modules/orchard.Projections

View File

@@ -71,7 +71,17 @@ namespace Orchard.Specs.Bindings {
var contentTypeDefinition = new ContentTypeDefinition(name, name);
cdm.StoreTypeDefinition(contentTypeDefinition);
cdm.AlterTypeDefinition(name, cfg => cfg.WithPart("CommonPart").WithPart("BodyPart").WithPart("AutoroutePart").WithPart("ContainablePart").Creatable().Draftable());
cdm.AlterTypeDefinition(name, cfg => cfg.WithPart("CommonPart").WithPart("BodyPart").WithPart("TitlePart").WithPart("ContainablePart").Creatable().Draftable());
cdm.AlterTypeDefinition(name,
cfg => cfg.WithPart("AutoroutePart",
builder => builder
.WithSetting("AutorouteSettings.AllowCustomPattern", "true")
.WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "false")
.WithSetting("AutorouteSettings.PatternDefinitions", "[{Name:'Title', Pattern: '{Content.Slug}', Description: 'my-list'}]")
.WithSetting("AutorouteSettings.DefaultPatternIndex", "0")
));
}
});
}

View File

@@ -9,12 +9,21 @@ namespace Orchard.Lists {
cfg=>cfg
.WithPart("CommonPart")
.WithPart("TitlePart")
.WithPart("AutoroutePart")
.WithPart("ContainerPart")
.WithPart("MenuPart")
.WithPart("AdminMenuPart", p => p.WithSetting("AdminMenuPartTypeSettings.DefaultPosition", "2"))
.Creatable());
ContentDefinitionManager.AlterTypeDefinition("List",
cfg => cfg.WithPart("AutoroutePart",
builder => builder
.WithSetting("AutorouteSettings.AllowCustomPattern", "true")
.WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "false")
.WithSetting("AutorouteSettings.PatternDefinitions", "[{Name:'Title', Pattern: '{Content.Slug}', Description: 'my-list'}]")
.WithSetting("AutorouteSettings.DefaultPatternIndex", "0")
));
return 4;
}

View File

@@ -6,5 +6,5 @@ Version: 1.3.0
OrchardVersion: 1.3.0
Description: Introduces a preconfigured container-enabled content type.
FeatureDescription: A basic container-enabled content type.
Dependencies: Contents, Containers, Navigation
Dependencies: Contents, Containers, Navigation, Orchard.Autoroute
Category: Content

View File

@@ -1,131 +0,0 @@
using System.Transactions;
using Orchard.Autoroute.Models;
using Orchard.Autoroute.Services;
using Orchard.ContentManagement;
using Orchard.ContentManagement.MetaData;
using Orchard.Core.Title.Models;
using Orchard.Data;
using Orchard.Data.Migration;
using Orchard.Environment.Configuration;
namespace UpgradeTo14 {
public class UpdateTo14DataMigration : DataMigrationImpl {
private readonly IContentManager _contentManager;
private readonly IAutorouteService _autorouteService;
private readonly ISessionFactoryHolder _sessionFactoryHolder;
private readonly ShellSettings _shellSettings;
public UpdateTo14DataMigration(
IContentManager contentManager,
IAutorouteService autorouteService,
ISessionFactoryHolder sessionFactoryHolder,
ShellSettings shellSettings) {
_contentManager = contentManager;
_autorouteService = autorouteService;
_sessionFactoryHolder = sessionFactoryHolder;
_shellSettings = shellSettings;
}
public int Create() {
return 1;
var sessionFactory = _sessionFactoryHolder.GetSessionFactory();
var session = sessionFactory.OpenSession();
// migrating pages
ContentDefinitionManager.AlterTypeDefinition("Page",
builder => builder
.WithPart("AutoroutePart")
.WithPart("TitlePart"));
var pages = _contentManager.HqlQuery().ForType("Page").List();
foreach(dynamic page in pages) {
var autoroutePart = ((ContentItem)page).As<AutoroutePart>();
var titlePart = ((ContentItem)page).As<TitlePart>();
using (new TransactionScope(TransactionScopeOption.Suppress)) {
var command = session.Connection.CreateCommand();
command.CommandText = string.Format("SELECT Title, Path FROM {0} WHERE ContentItemRecord_Id = {1}", GetPrefixedTableName("Routable_RoutePartRecord"), autoroutePart.ContentItem.Id);
var reader = command.ExecuteReader();
reader.Read();
var title = reader.GetString(0);
var path = reader.GetString(1);
reader.Close();
autoroutePart.DisplayAlias = path;
titlePart.Title = title;
}
_autorouteService.PublishAlias(autoroutePart);
}
ContentDefinitionManager.AlterTypeDefinition("Page", builder => builder.RemovePart("RoutePart"));
// migrating blogs
ContentDefinitionManager.AlterTypeDefinition("Blog", builder => builder.WithPart("AutoroutePart").WithPart("TitlePart"));
var blogs = _contentManager.HqlQuery().ForType("Blog").List();
foreach (dynamic blog in blogs) {
var autoroutePart = ((ContentItem)blog).As<AutoroutePart>();
var titlePart = ((ContentItem)blog).As<TitlePart>();
using (new TransactionScope(TransactionScopeOption.Suppress)) {
var command = session.Connection.CreateCommand();
command.CommandText = string.Format("SELECT Title, Path FROM {0} WHERE ContentItemRecord_Id = {1}", GetPrefixedTableName("Routable_RoutePartRecord"), autoroutePart.ContentItem.Id);
var reader = command.ExecuteReader();
reader.Read();
var title = reader.GetString(0);
var path = reader.GetString(1);
reader.Close();
autoroutePart.DisplayAlias = path;
titlePart.Title = title;
}
_autorouteService.PublishAlias(autoroutePart);
}
// migrating blog posts
ContentDefinitionManager.AlterTypeDefinition("BlogPost", builder => builder.WithPart("AutoroutePart").WithPart("TitlePart"));
var blogposts = _contentManager.HqlQuery().ForType("BlogPost").List();
foreach (dynamic blogpost in blogposts) {
var autoroutePart = ((ContentItem)blogpost).As<AutoroutePart>();
var titlePart = ((ContentItem)blogpost).As<TitlePart>();
using (new TransactionScope(TransactionScopeOption.Suppress)) {
var command = session.Connection.CreateCommand();
command.CommandText = string.Format("SELECT Title, Path FROM {0} WHERE ContentItemRecord_Id = {1}", GetPrefixedTableName("Routable_RoutePartRecord"), autoroutePart.ContentItem.Id);
var reader = command.ExecuteReader();
reader.Read();
var title = reader.GetString(0);
var path = reader.GetString(1);
reader.Close();
autoroutePart.DisplayAlias = path;
titlePart.Title = title;
}
_autorouteService.PublishAlias(autoroutePart);
}
// migrating containers/list
// todo
_autorouteService.CreatePattern("Page", "Title", "{Content.Slug}", "about-us", true);
_autorouteService.CreatePattern("Blog", "Title", "{Content.Slug}", "my-blog", true);
_autorouteService.CreatePattern("BlogPost", "Blog and Title", "{Content.Container.Path}/{Content.Slug}", "my-blog/a-blog-post", true);
return 1;
}
private string GetPrefixedTableName(string tableName) {
if(string.IsNullOrWhiteSpace(_shellSettings.DataTablePrefix)) {
return tableName;
}
return _shellSettings.DataTablePrefix + "_" + tableName;
}
}
}

View File

@@ -90,7 +90,6 @@
<ItemGroup>
<Compile Include="AdminMenu.cs" />
<Compile Include="Controllers\AdminController.cs" />
<Compile Include="Migrations.cs" />
<Compile Include="ViewModels\MigrateViewModel.cs" />
</ItemGroup>
<ItemGroup>