From b1f9a33ed7b14e60af2ad6cdd3edd768b3388269 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 3 Dec 2010 22:57:42 -0800 Subject: [PATCH 01/18] Flatten "Widgets" views --HG-- branch : dev rename : src/Orchard.Web/Modules/Orchard.Widgets/Views/Items/Content-WidgetPage.cshtml => src/Orchard.Web/Modules/Orchard.Widgets/Views/Content-WidgetPage.cshtml rename : src/Orchard.Web/Modules/Orchard.Widgets/Views/EditorTemplates/Parts/Widgets.LayerPart.cshtml => src/Orchard.Web/Modules/Orchard.Widgets/Views/EditorTemplates/Parts.Widgets.LayerPart.cshtml rename : src/Orchard.Web/Modules/Orchard.Widgets/Views/EditorTemplates/Parts/Widgets.WidgetPart.cshtml => src/Orchard.Web/Modules/Orchard.Widgets/Views/EditorTemplates/Parts.Widgets.WidgetPart.cshtml rename : src/Orchard.Web/Modules/Orchard.Widgets/Views/Items/Widget.Edit.cshtml => src/Orchard.Web/Modules/Orchard.Widgets/Views/Widget.Edit.cshtml rename : src/Orchard.Web/Modules/Orchard.Widgets/Views/Items/Widget.cshtml => src/Orchard.Web/Modules/Orchard.Widgets/Views/Widget.cshtml --- .../Orchard.Widgets/Drivers/LayerPartDriver.cs | 2 +- .../Drivers/WidgetPartDriver.cs | 2 +- .../Orchard.Widgets/Orchard.Widgets.csproj | 18 ++++++++++++------ .../{Items => }/Content-WidgetPage.cshtml | 0 ...t.cshtml => Parts.Widgets.LayerPart.cshtml} | 0 ....cshtml => Parts.Widgets.WidgetPart.cshtml} | 0 .../Parts/Widgets.WidgetBagPart.cshtml | 8 -------- .../Views/{Items => }/Widget.Edit.cshtml | 0 .../Views/{Items => }/Widget.cshtml | 0 9 files changed, 14 insertions(+), 16 deletions(-) rename src/Orchard.Web/Modules/Orchard.Widgets/Views/{Items => }/Content-WidgetPage.cshtml (100%) rename src/Orchard.Web/Modules/Orchard.Widgets/Views/EditorTemplates/{Parts/Widgets.LayerPart.cshtml => Parts.Widgets.LayerPart.cshtml} (100%) rename src/Orchard.Web/Modules/Orchard.Widgets/Views/EditorTemplates/{Parts/Widgets.WidgetPart.cshtml => Parts.Widgets.WidgetPart.cshtml} (100%) delete mode 100644 src/Orchard.Web/Modules/Orchard.Widgets/Views/EditorTemplates/Parts/Widgets.WidgetBagPart.cshtml rename src/Orchard.Web/Modules/Orchard.Widgets/Views/{Items => }/Widget.Edit.cshtml (100%) rename src/Orchard.Web/Modules/Orchard.Widgets/Views/{Items => }/Widget.cshtml (100%) diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/LayerPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/LayerPartDriver.cs index 8009bca01..9267afece 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/LayerPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/LayerPartDriver.cs @@ -28,7 +28,7 @@ namespace Orchard.Widgets.Drivers { protected override DriverResult Editor(LayerPart layerPart, dynamic shapeHelper) { return ContentShape("Parts_Widgets_LayerPart", - () => shapeHelper.EditorTemplate(TemplateName: "Parts/Widgets.LayerPart", Model: layerPart, Prefix: Prefix)); + () => shapeHelper.EditorTemplate(TemplateName: "Parts.Widgets.LayerPart", Model: layerPart, Prefix: Prefix)); } protected override DriverResult Editor(LayerPart layerPart, IUpdateModel updater, dynamic shapeHelper) { diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/WidgetPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/WidgetPartDriver.cs index 889595ee2..b6464358a 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/WidgetPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/WidgetPartDriver.cs @@ -20,7 +20,7 @@ namespace Orchard.Widgets.Drivers { widgetPart.AvailableLayers = _widgetsService.GetLayers(); return ContentShape("Parts_Widgets_WidgetPart", - () => shapeHelper.EditorTemplate(TemplateName: "Parts/Widgets.WidgetPart", Model: widgetPart, Prefix: Prefix)); + () => shapeHelper.EditorTemplate(TemplateName: "Parts.Widgets.WidgetPart", Model: widgetPart, Prefix: Prefix)); } protected override DriverResult Editor(WidgetPart widgetPart, IUpdateModel updater, dynamic shapeHelper) { diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Orchard.Widgets.csproj b/src/Orchard.Web/Modules/Orchard.Widgets/Orchard.Widgets.csproj index 4e9284f5c..d5d1068cc 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/Orchard.Widgets.csproj +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Orchard.Widgets.csproj @@ -105,13 +105,10 @@ - - + + - - - - + @@ -124,6 +121,15 @@ Designer + + + + + + + + + + + + + + + + + + @@ -56,11 +72,7 @@ - - - - From b12a25e169e20e867688678009463143d7b949f2 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 4 Dec 2010 15:29:35 -0800 Subject: [PATCH 10/18] Fix unit tests --HG-- branch : dev --- src/Orchard.Tests/Events/EventTests.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Orchard.Tests/Events/EventTests.cs b/src/Orchard.Tests/Events/EventTests.cs index 585876a0a..e01498b87 100644 --- a/src/Orchard.Tests/Events/EventTests.cs +++ b/src/Orchard.Tests/Events/EventTests.cs @@ -207,27 +207,21 @@ namespace Orchard.Tests.Events { } public class StubEventHandler2 : ITestEventHandler { public void Increment() { - throw new NotImplementedException(); } public void Sum(int a) { - throw new NotImplementedException(); } public void Sum(int a, int b) { - throw new NotImplementedException(); } public void Sum(int a, int b, int c) { - throw new NotImplementedException(); } public void Substract(int a, int b) { - throw new NotImplementedException(); } public void Concat(string a, string b, string c) { - throw new NotImplementedException(); } public IEnumerable Gather(int a, string b) { From f794b3f955f3140b567b74480736dff19e7c647f Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 4 Dec 2010 15:31:24 -0800 Subject: [PATCH 11/18] Split feature lifetime events to "xx'ing" and "xx'ed" --HG-- branch : dev --- .../DefaultIndexingUpdater.cs | 25 +++++++++++------ .../DefaultPackagingUpdater.cs | 27 ++++++++++++++----- .../Orchard.Roles/DefaultRoleUpdater.cs | 26 ++++++++++++++---- .../Migration/DataMigrationCoordinator.cs | 23 ++++++++++++---- .../Environment/IOrchardShellEvents.cs | 12 ++++++--- .../State/ShellStateCoordinator.cs | 12 ++++++--- 6 files changed, 93 insertions(+), 32 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Indexing/DefaultIndexingUpdater.cs b/src/Orchard.Web/Modules/Orchard.Indexing/DefaultIndexingUpdater.cs index cf4ceb089..9312e29e0 100644 --- a/src/Orchard.Web/Modules/Orchard.Indexing/DefaultIndexingUpdater.cs +++ b/src/Orchard.Web/Modules/Orchard.Indexing/DefaultIndexingUpdater.cs @@ -1,14 +1,11 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; using Orchard.Environment; +using Orchard.Environment.Extensions.Models; using Orchard.Tasks.Indexing; using Orchard.ContentManagement; namespace Orchard.Indexing { public class DefaultIndexingUpdater : IFeatureEventHandler { - private readonly IIndexingTaskManager _indexingTaskManager; private readonly IContentManager _contentManager; @@ -17,10 +14,16 @@ namespace Orchard.Indexing { _contentManager = contentManager; } - public void Install(Environment.Extensions.Models.Feature feature) { + public void Installing(Feature feature) { } - public void Enable(Environment.Extensions.Models.Feature feature) { + public void Installed(Feature feature) { + } + + public void Enabling(Feature feature) { + } + + public void Enabled(Feature feature) { // create indexing tasks for all currently existing content, even when the module is enabled again // as some content might have been created while this module was not active, and indexing tasks // would not exist for them, resulting in an uncomplete index. @@ -30,10 +33,16 @@ namespace Orchard.Indexing { } } - public void Disable(Environment.Extensions.Models.Feature feature) { + public void Disabling(Feature feature) { } - public void Uninstall(Environment.Extensions.Models.Feature feature) { + public void Disabled(Feature feature) { + } + + public void Uninstalling(Feature feature) { + } + + public void Uninstalled(Feature feature) { } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Packaging/DefaultPackagingUpdater.cs b/src/Orchard.Web/Modules/Orchard.Packaging/DefaultPackagingUpdater.cs index 5be632a8c..59ea45e2d 100644 --- a/src/Orchard.Web/Modules/Orchard.Packaging/DefaultPackagingUpdater.cs +++ b/src/Orchard.Web/Modules/Orchard.Packaging/DefaultPackagingUpdater.cs @@ -1,4 +1,5 @@ -using Orchard.Environment; +using System; +using Orchard.Environment; using Orchard.Environment.Extensions; using Orchard.Environment.Extensions.Models; using Orchard.Localization; @@ -15,17 +16,31 @@ namespace Orchard.Packaging { public Localizer T { get; set; } - public void Install(Feature feature) { - _packagingSourceManager.AddSource( "Orchard Extensions Gallery", "http://feed.nuget.org/ctp2/odata/v1" ); + public void Installing(Feature feature) { } - public void Enable(Feature feature) { + public void Installed(Feature feature) { + if (feature.Descriptor.Id == "Gallery") { + _packagingSourceManager.AddSource("Orchard Extensions Gallery", "http://feed.nuget.org/ctp2/odata/v1"); + } } - public void Disable(Feature feature) { + public void Enabling(Feature feature) { } - public void Uninstall(Feature feature) { + public void Enabled(Feature feature) { + } + + public void Disabling(Feature feature) { + } + + public void Disabled(Feature feature) { + } + + public void Uninstalling(Feature feature) { + } + + public void Uninstalled(Feature feature) { } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Roles/DefaultRoleUpdater.cs b/src/Orchard.Web/Modules/Orchard.Roles/DefaultRoleUpdater.cs index 1fe867fa4..1b4c69d64 100644 --- a/src/Orchard.Web/Modules/Orchard.Roles/DefaultRoleUpdater.cs +++ b/src/Orchard.Web/Modules/Orchard.Roles/DefaultRoleUpdater.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using JetBrains.Annotations; using Orchard.Environment; @@ -24,15 +25,30 @@ namespace Orchard.Roles { public ILogger Logger { get; set; } - void IFeatureEventHandler.Install(Feature feature) { + void IFeatureEventHandler.Installing(Feature feature) { AddDefaultRolesForFeature(feature); } - void IFeatureEventHandler.Enable(Feature feature) {} + void IFeatureEventHandler.Installed(Feature feature) { + } - void IFeatureEventHandler.Disable(Feature feature) {} + void IFeatureEventHandler.Enabling(Feature feature) { + } - void IFeatureEventHandler.Uninstall(Feature feature) {} + void IFeatureEventHandler.Enabled(Feature feature) { + } + + void IFeatureEventHandler.Disabling(Feature feature) { + } + + void IFeatureEventHandler.Disabled(Feature feature) { + } + + void IFeatureEventHandler.Uninstalling(Feature feature) { + } + + void IFeatureEventHandler.Uninstalled(Feature feature) { + } public void AddDefaultRolesForFeature(Feature feature) { var featureName = feature.Descriptor.Id; diff --git a/src/Orchard/Data/Migration/DataMigrationCoordinator.cs b/src/Orchard/Data/Migration/DataMigrationCoordinator.cs index 58573ec95..0438db2ed 100644 --- a/src/Orchard/Data/Migration/DataMigrationCoordinator.cs +++ b/src/Orchard/Data/Migration/DataMigrationCoordinator.cs @@ -1,4 +1,5 @@ -using Orchard.Environment; +using System; +using Orchard.Environment; using Orchard.Environment.Extensions.Models; namespace Orchard.Data.Migration { @@ -21,18 +22,30 @@ namespace Orchard.Data.Migration { _dataMigrationManager = dataMigrationManager; } - public void Install(Feature feature) { + public void Installing(Feature feature) { var featureName = feature.Descriptor.Id; _dataMigrationManager.Update(featureName); } - public void Enable(Feature feature) { + public void Installed(Feature feature) { } - public void Disable(Feature feature) { + public void Enabling(Feature feature) { } - public void Uninstall(Feature feature) { + public void Enabled(Feature feature) { + } + + public void Disabling(Feature feature) { + } + + public void Disabled(Feature feature) { + } + + public void Uninstalling(Feature feature) { + } + + public void Uninstalled(Feature feature) { var featureName = feature.Descriptor.Id; if ( _dataMigrationManager.IsFeatureAlreadyInstalled(featureName) ) { _dataMigrationManager.Uninstall(featureName); diff --git a/src/Orchard/Environment/IOrchardShellEvents.cs b/src/Orchard/Environment/IOrchardShellEvents.cs index d845199b1..889dc8cd9 100644 --- a/src/Orchard/Environment/IOrchardShellEvents.cs +++ b/src/Orchard/Environment/IOrchardShellEvents.cs @@ -8,9 +8,13 @@ namespace Orchard.Environment { } public interface IFeatureEventHandler : IEventHandler { - void Install(Feature feature); - void Enable(Feature feature); - void Disable(Feature feature); - void Uninstall(Feature feature); + void Installing(Feature feature); + void Installed(Feature feature); + void Enabling(Feature feature); + void Enabled(Feature feature); + void Disabling(Feature feature); + void Disabled(Feature feature); + void Uninstalling(Feature feature); + void Uninstalled(Feature feature); } } diff --git a/src/Orchard/Environment/State/ShellStateCoordinator.cs b/src/Orchard/Environment/State/ShellStateCoordinator.cs index 5f9d36972..03e8eb20d 100644 --- a/src/Orchard/Environment/State/ShellStateCoordinator.cs +++ b/src/Orchard/Environment/State/ShellStateCoordinator.cs @@ -157,28 +157,32 @@ namespace Orchard.Environment.State { // lower enabled states in reverse order foreach (var entry in allEntries.Reverse().Where(entry => entry.FeatureState.EnableState == ShellFeatureState.State.Falling)) { Logger.Information("Disabling feature '{0}'", entry.Feature.Descriptor.Id); - _featureEvents.Disable(entry.Feature); + _featureEvents.Disabling(entry.Feature); _stateManager.UpdateEnabledState(entry.FeatureState, ShellFeatureState.State.Down); + _featureEvents.Disabled(entry.Feature); } // lower installed states in reverse order foreach (var entry in allEntries.Reverse().Where(entry => entry.FeatureState.InstallState == ShellFeatureState.State.Falling)) { Logger.Information("Uninstalling feature '{0}'", entry.Feature.Descriptor.Id); - _featureEvents.Uninstall(entry.Feature); + _featureEvents.Uninstalling(entry.Feature); _stateManager.UpdateInstalledState(entry.FeatureState, ShellFeatureState.State.Down); + _featureEvents.Uninstalled(entry.Feature); } // raise install and enabled states in order foreach (var entry in allEntries.Where(entry => IsRising(entry.FeatureState))) { if (entry.FeatureState.InstallState == ShellFeatureState.State.Rising) { Logger.Information("Installing feature '{0}'", entry.Feature.Descriptor.Id); - _featureEvents.Install(entry.Feature); + _featureEvents.Installing(entry.Feature); _stateManager.UpdateInstalledState(entry.FeatureState, ShellFeatureState.State.Up); + _featureEvents.Installed(entry.Feature); } if (entry.FeatureState.EnableState == ShellFeatureState.State.Rising) { Logger.Information("Enabling feature '{0}'", entry.Feature.Descriptor.Id); - _featureEvents.Enable(entry.Feature); + _featureEvents.Enabling(entry.Feature); _stateManager.UpdateEnabledState(entry.FeatureState, ShellFeatureState.State.Up); + _featureEvents.Enabled(entry.Feature); } } From 63cbb03b93fb2fca04ec5005c2e66b5b8f082f37 Mon Sep 17 00:00:00 2001 From: Suha Can Date: Sat, 4 Dec 2010 17:33:02 -0800 Subject: [PATCH 12/18] Adding unit tests for the Comments module. --HG-- branch : dev --- .../Comments/Services/CommentServiceTests.cs | 211 ++++++++++++++++++ .../Orchard.Tests.Modules.csproj | 6 + .../Handlers/CommentPartHandler.cs | 2 - 3 files changed, 217 insertions(+), 2 deletions(-) create mode 100644 src/Orchard.Tests.Modules/Comments/Services/CommentServiceTests.cs diff --git a/src/Orchard.Tests.Modules/Comments/Services/CommentServiceTests.cs b/src/Orchard.Tests.Modules/Comments/Services/CommentServiceTests.cs new file mode 100644 index 000000000..66354e7d9 --- /dev/null +++ b/src/Orchard.Tests.Modules/Comments/Services/CommentServiceTests.cs @@ -0,0 +1,211 @@ +using System; +using System.Collections.Generic; +using Autofac; +using JetBrains.Annotations; +using Moq; +using NUnit.Framework; +using Orchard.Comments.Handlers; +using Orchard.Comments.Models; +using Orchard.Comments.Services; +using Orchard.ContentManagement; +using Orchard.ContentManagement.Drivers; +using Orchard.ContentManagement.Handlers; +using Orchard.ContentManagement.MetaData; +using Orchard.ContentManagement.Records; +using Orchard.Core.Common.Handlers; +using Orchard.Core.Common.Models; +using Orchard.Data; +using Orchard.DisplayManagement; +using Orchard.DisplayManagement.Descriptors; +using Orchard.DisplayManagement.Implementation; +using Orchard.Environment; +using Orchard.Environment.Extensions; +using Orchard.Security; +using Orchard.Tests.Stubs; +using Orchard.UI.Notify; + +namespace Orchard.Tests.Modules.Comments.Services { + [TestFixture] + public class CommentServiceTests : DatabaseEnabledTestsBase { + private IContentManager _contentManager; + private ICommentService _commentService; + + public override void Register(ContainerBuilder builder) { + builder.RegisterType().As(); + builder.RegisterType().As(); + builder.RegisterType().As(); + builder.RegisterType().As(); + builder.RegisterInstance(new Mock().Object); + builder.RegisterInstance(new Mock().Object); + builder.RegisterInstance(new Mock().Object); + builder.RegisterInstance(new Mock().Object); + builder.RegisterInstance(new Mock().Object); + builder.RegisterInstance(new Mock().Object); + builder.RegisterType().As(); + builder.RegisterType().As(); + builder.RegisterType().As(); + builder.RegisterType().As(); + builder.RegisterType().As(); + builder.RegisterType().As(); + builder.RegisterType().As(); + builder.RegisterType().As(); + builder.RegisterType().As(); + builder.RegisterType().As(); + builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>)); + } + + public override void Init() { + base.Init(); + _commentService = _container.Resolve(); + _contentManager = _container.Resolve(); + } + + + protected override IEnumerable DatabaseTypes { + get { + return new[] { + typeof(CommentPartRecord), + typeof(ContentItemRecord), + typeof(ContentItemVersionRecord), + typeof(ContentTypeRecord), + }; + } + } + + [Test] + public void CommentedItemShouldHaveACommentPart() { + var commentedItem = _contentManager.New("commentedItem"); + _contentManager.Create(commentedItem); + _contentManager.Create(commentedItem, VersionOptions.Published); + + Assert.That(commentedItem.As(), Is.Not.Null); + } + + [Test] + public void GetCommentsShouldReturnAllComments() { + for (int i = 0; i < 12; i++) { + var commentedItem = _contentManager.New("commentedItem"); + _contentManager.Create(commentedItem); + _contentManager.Create(commentedItem, VersionOptions.Published); + + } + + Assert.That(_commentService.GetComments().Count(), Is.EqualTo(12)); + } + + [Test] + public void GetCommentedContentShouldReturnCommentedContentItem() { + var commentedItem = _contentManager.New("commentedItem"); + _contentManager.Create(commentedItem); + _contentManager.Create(commentedItem, VersionOptions.Published); + int commentId = commentedItem.As().Id; + + Assert.That(_commentService.GetCommentedContent(commentId), Is.Not.Null); + } + + [Test] + public void UpdateShouldChangeComment() { + var commentedItem = _contentManager.New("commentedItem"); + _contentManager.Create(commentedItem); + _contentManager.Create(commentedItem, VersionOptions.Published); + int commentId = commentedItem.As().Id; + + Assert.That(_commentService.GetComment(commentId).Record.Author, Is.Null.Or.Empty); + + _commentService.UpdateComment(commentId, "test", "", "", "new text", CommentStatus.Pending); + + Assert.That(_commentService.GetComment(commentId).Record.Author, Is.EqualTo("test")); + } + + [Test] + public void CommentsShouldBePendingByDefault() { + var commentedItem = _contentManager.New("commentedItem"); + _contentManager.Create(commentedItem); + _contentManager.Create(commentedItem, VersionOptions.Published); + int commentId = commentedItem.As().Id; + + Assert.That(_commentService.GetComment(commentId).Record.Status, Is.EqualTo(CommentStatus.Pending)); + } + + [Test] + public void ApproveShouldUpdateCommentStatus() { + var commentedItem = _contentManager.New("commentedItem"); + _contentManager.Create(commentedItem); + _contentManager.Create(commentedItem, VersionOptions.Published); + int commentId = commentedItem.As().Id; + _commentService.ApproveComment(commentId); + + Assert.That(_commentService.GetComment(commentId).Record.Status, Is.EqualTo(CommentStatus.Approved)); + } + + [Test] + public void UnapproveShouldPendComment() { + var commentedItem = _contentManager.New("commentedItem"); + _contentManager.Create(commentedItem); + _contentManager.Create(commentedItem, VersionOptions.Published); + int commentId = commentedItem.As().Id; + _commentService.ApproveComment(commentId); + + Assert.That(_commentService.GetComment(commentId).Record.Status, Is.EqualTo(CommentStatus.Approved)); + + _commentService.UnapproveComment(commentId); + + Assert.That(_commentService.GetComment(commentId).Record.Status, Is.EqualTo(CommentStatus.Pending)); + } + + [Test] + public void MarkAsSpamShouldFlagComments() { + var commentedItem = _contentManager.New("commentedItem"); + _contentManager.Create(commentedItem); + _contentManager.Create(commentedItem, VersionOptions.Published); + int commentId = commentedItem.As().Id; + _commentService.ApproveComment(commentId); + + Assert.That(_commentService.GetComment(commentId).Record.Status, Is.EqualTo(CommentStatus.Approved)); + + _commentService.MarkCommentAsSpam(commentId); + + Assert.That(_commentService.GetComment(commentId).Record.Status, Is.EqualTo(CommentStatus.Spam)); + } + + [Test] + public void DeleteShouldRemoveComments() { + var commentIds = new int[12]; + + for (int i = 0; i < 12; i++) { + var commentedItem = _contentManager.New("commentedItem"); + _contentManager.Create(commentedItem); + _contentManager.Create(commentedItem, VersionOptions.Published); + commentIds[i] = commentedItem.As().Id; + } + + Assert.That(_commentService.GetComments().Count(), Is.EqualTo(12)); + + for (int i = 0; i < 12; i++) { + _commentService.DeleteComment(commentIds[i]); + } + } + } + + [UsedImplicitly] + public class CommentedItemHandler : ContentHandler { + public CommentedItemHandler() { + Filters.Add(new ActivatingFilter("commentedItem")); + Filters.Add(new ActivatingFilter("commentedItem")); + Filters.Add(new ActivatingFilter("commentedItem")); + } + } + + public class CommentedItem : ContentPart { + } + + public class CommentedItemDriver : ContentPartDriver { + public static readonly string ContentTypeName = "commentedItem"; + } + + public class StubCommentValidator : ICommentValidator { + public bool ValidateComment(CommentPart commentPart) { + return true; + } + } +} diff --git a/src/Orchard.Tests.Modules/Orchard.Tests.Modules.csproj b/src/Orchard.Tests.Modules/Orchard.Tests.Modules.csproj index 8b3915057..02b5112a1 100644 --- a/src/Orchard.Tests.Modules/Orchard.Tests.Modules.csproj +++ b/src/Orchard.Tests.Modules/Orchard.Tests.Modules.csproj @@ -135,6 +135,7 @@ + @@ -179,6 +180,10 @@ {C0C45321-B51D-4D8D-9B7B-AA4C2E0B2962} Orchard.CodeGeneration + + {14C049FD-B35B-415A-A824-87F26B26E7FD} + Orchard.Comments + {D9A7B330-CD22-4DA1-A95A-8DE1982AD8EB} Orchard.Media @@ -252,6 +257,7 @@ + - + From cda72759a1695806da7043c1e9f04f2dff6cd63c Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 4 Dec 2010 22:04:38 -0800 Subject: [PATCH 14/18] Fix incorrect command --HG-- branch : dev --- Orchard.proj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Orchard.proj b/Orchard.proj index 2742a503a..ac22d41e1 100644 --- a/Orchard.proj +++ b/Orchard.proj @@ -331,7 +331,7 @@ - + From 26888dd3603f029189ad7f5a24d359850f550ded Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 4 Dec 2010 22:04:50 -0800 Subject: [PATCH 15/18] Re-enable ignored specflow tests --HG-- branch : dev --- src/Orchard.Specs/MultiTenancy.feature | 3 - src/Orchard.Specs/MultiTenancy.feature.cs | 248 +++++++++++----------- src/Orchard.Specs/Orchard.Specs.csproj | 1 + 3 files changed, 122 insertions(+), 130 deletions(-) diff --git a/src/Orchard.Specs/MultiTenancy.feature b/src/Orchard.Specs/MultiTenancy.feature index 1ff0fa79f..8890a98a0 100644 --- a/src/Orchard.Specs/MultiTenancy.feature +++ b/src/Orchard.Specs/MultiTenancy.feature @@ -3,7 +3,6 @@ As a root Orchard system operator I want to create and manage tenant configurations -@ignore Scenario: Default site is listed Given I have installed Orchard And I have installed "Orchard.MultiTenancy" @@ -115,7 +114,6 @@ Scenario: An existing initialized tenant cannot have its database option cleared And I should see "

Scott

" And I should not see "Allow the tenant to set up the database" -@ignore Scenario: Default tenant cannot be disabled Given I have installed Orchard And I have installed "Orchard.MultiTenancy" @@ -166,7 +164,6 @@ Scenario: A running tenant which is disabled can be enabled And I am redirected Then I should see "
Default\""); -#line 13 +#line 12 testRunner.And("the status should be 200 \"OK\""); #line hidden testRunner.CollectScenarioErrors(); @@ -83,17 +81,17 @@ testRunner.And("the status should be 200 \"OK\""); public virtual void NewTenantFieldsAreRequired() { TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("New tenant fields are required", ((string[])(null))); -#line 15 +#line 14 this.ScenarioSetup(scenarioInfo); -#line 16 +#line 15 testRunner.Given("I have installed Orchard"); -#line 17 +#line 16 testRunner.And("I have installed \"Orchard.MultiTenancy\""); -#line 18 +#line 17 testRunner.When("I go to \"Admin/MultiTenancy/Add\""); -#line 19 +#line 18 testRunner.And("I hit \"Save\""); -#line 20 +#line 19 testRunner.Then("I should see \"is required\""); #line hidden testRunner.CollectScenarioErrors(); @@ -104,13 +102,13 @@ testRunner.Then("I should see \"is required\""); public virtual void ANewTenantIsCreated() { TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("A new tenant is created", ((string[])(null))); -#line 22 +#line 21 this.ScenarioSetup(scenarioInfo); -#line 23 +#line 22 testRunner.Given("I have installed Orchard"); -#line 24 +#line 23 testRunner.And("I have installed \"Orchard.MultiTenancy\""); -#line 25 +#line 24 testRunner.When("I go to \"Admin/MultiTenancy/Add\""); #line hidden TechTalk.SpecFlow.Table table1 = new TechTalk.SpecFlow.Table(new string[] { @@ -119,15 +117,15 @@ testRunner.When("I go to \"Admin/MultiTenancy/Add\""); table1.AddRow(new string[] { "Name", "Scott"}); -#line 26 +#line 25 testRunner.And("I fill in", ((string)(null)), table1); -#line 29 +#line 28 testRunner.And("I hit \"Save\""); -#line 30 +#line 29 testRunner.And("I am redirected"); -#line 31 +#line 30 testRunner.Then("I should see \"

Scott

\""); -#line 32 +#line 31 testRunner.And("the status should be 200 \"OK\""); #line hidden testRunner.CollectScenarioErrors(); @@ -138,13 +136,13 @@ testRunner.And("the status should be 200 \"OK\""); public virtual void ANewTenantIsCreatedWithUninitializedState() { TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("A new tenant is created with uninitialized state", ((string[])(null))); -#line 34 +#line 33 this.ScenarioSetup(scenarioInfo); -#line 35 +#line 34 testRunner.Given("I have installed Orchard"); -#line 36 +#line 35 testRunner.And("I have installed \"Orchard.MultiTenancy\""); -#line 37 +#line 36 testRunner.When("I go to \"Admin/MultiTenancy/Add\""); #line hidden TechTalk.SpecFlow.Table table2 = new TechTalk.SpecFlow.Table(new string[] { @@ -153,15 +151,15 @@ testRunner.When("I go to \"Admin/MultiTenancy/Add\""); table2.AddRow(new string[] { "Name", "Scott"}); -#line 38 +#line 37 testRunner.And("I fill in", ((string)(null)), table2); -#line 41 +#line 40 testRunner.And("I hit \"Save\""); -#line 42 +#line 41 testRunner.And("I am redirected"); -#line 43 +#line 42 testRunner.Then("I should see \"
  • \""); -#line 44 +#line 43 testRunner.And("the status should be 200 \"OK\""); #line hidden testRunner.CollectScenarioErrors(); @@ -172,13 +170,13 @@ testRunner.And("the status should be 200 \"OK\""); public virtual void ANewTenantGoesToTheSetupScreen() { TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("A new tenant goes to the setup screen", ((string[])(null))); -#line 46 +#line 45 this.ScenarioSetup(scenarioInfo); -#line 47 +#line 46 testRunner.Given("I have installed Orchard"); -#line 48 +#line 47 testRunner.And("I have installed \"Orchard.MultiTenancy\""); -#line 49 +#line 48 testRunner.When("I go to \"Admin/MultiTenancy/Add\""); #line hidden TechTalk.SpecFlow.Table table3 = new TechTalk.SpecFlow.Table(new string[] { @@ -190,17 +188,17 @@ testRunner.When("I go to \"Admin/MultiTenancy/Add\""); table3.AddRow(new string[] { "RequestUrlHost", "scott.example.org"}); -#line 50 +#line 49 testRunner.And("I fill in", ((string)(null)), table3); -#line 54 +#line 53 testRunner.And("I hit \"Save\""); -#line 55 +#line 54 testRunner.And("I go to \"/Setup\" on host scott.example.org"); -#line 56 +#line 55 testRunner.Then("I should see \"Welcome to Orchard\""); -#line 57 +#line 56 testRunner.And("I should see \"Finish Setup\""); -#line 58 +#line 57 testRunner.And("the status should be 200 \"OK\""); #line hidden testRunner.CollectScenarioErrors(); @@ -211,13 +209,13 @@ testRunner.And("the status should be 200 \"OK\""); public virtual void ANewTenantWithPreconfiguredDatabaseGoesToTheSetupScreen() { TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("A new tenant with preconfigured database goes to the setup screen", ((string[])(null))); -#line 60 +#line 59 this.ScenarioSetup(scenarioInfo); -#line 61 +#line 60 testRunner.Given("I have installed Orchard"); -#line 62 +#line 61 testRunner.And("I have installed \"Orchard.MultiTenancy\""); -#line 63 +#line 62 testRunner.When("I go to \"Admin/MultiTenancy/Add\""); #line hidden TechTalk.SpecFlow.Table table4 = new TechTalk.SpecFlow.Table(new string[] { @@ -232,21 +230,21 @@ testRunner.When("I go to \"Admin/MultiTenancy/Add\""); table4.AddRow(new string[] { "DataProvider", "SqlCe"}); -#line 64 +#line 63 testRunner.And("I fill in", ((string)(null)), table4); -#line 69 +#line 68 testRunner.And("I hit \"Save\""); -#line 70 +#line 69 testRunner.And("I am redirected"); -#line 71 +#line 70 testRunner.And("I go to \"/Setup\" on host scott.example.org"); -#line 72 +#line 71 testRunner.Then("I should see \"Welcome to Orchard\""); -#line 73 +#line 72 testRunner.And("I should see \"Finish Setup\""); -#line 74 +#line 73 testRunner.And("I should not see \"SQL Server Compact\""); -#line 75 +#line 74 testRunner.And("the status should be 200 \"OK\""); #line hidden testRunner.CollectScenarioErrors(); @@ -257,13 +255,13 @@ testRunner.And("the status should be 200 \"OK\""); public virtual void ANewTenantRunsTheSetup() { TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("A new tenant runs the setup", ((string[])(null))); -#line 77 +#line 76 this.ScenarioSetup(scenarioInfo); -#line 78 +#line 77 testRunner.Given("I have installed Orchard"); -#line 79 +#line 78 testRunner.And("I have installed \"Orchard.MultiTenancy\""); -#line 80 +#line 79 testRunner.When("I go to \"Admin/MultiTenancy/Add\""); #line hidden TechTalk.SpecFlow.Table table5 = new TechTalk.SpecFlow.Table(new string[] { @@ -275,11 +273,11 @@ testRunner.When("I go to \"Admin/MultiTenancy/Add\""); table5.AddRow(new string[] { "RequestUrlHost", "scott.example.org"}); -#line 81 +#line 80 testRunner.And("I fill in", ((string)(null)), table5); -#line 85 +#line 84 testRunner.And("I hit \"Save\""); -#line 86 +#line 85 testRunner.And("I go to \"/Setup\" on host scott.example.org"); #line hidden TechTalk.SpecFlow.Table table6 = new TechTalk.SpecFlow.Table(new string[] { @@ -294,15 +292,15 @@ testRunner.And("I go to \"/Setup\" on host scott.example.org"); table6.AddRow(new string[] { "ConfirmPassword", "6655321"}); -#line 87 +#line 86 testRunner.And("I fill in", ((string)(null)), table6); -#line 92 +#line 91 testRunner.And("I hit \"Finish Setup\""); -#line 93 +#line 92 testRunner.And("I go to \"/Default.aspx\""); -#line 94 +#line 93 testRunner.Then("I should see \"Scott Site\""); -#line 95 +#line 94 testRunner.And("I should see \"Welcome\""); #line hidden testRunner.CollectScenarioErrors(); @@ -313,13 +311,13 @@ testRunner.And("I should see \"Welcome\""); public virtual void AnExistingInitializedTenantCannotHaveItsDatabaseOptionCleared() { TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("An existing initialized tenant cannot have its database option cleared", ((string[])(null))); -#line 97 +#line 96 this.ScenarioSetup(scenarioInfo); -#line 98 +#line 97 testRunner.Given("I have installed Orchard"); -#line 99 +#line 98 testRunner.And("I have installed \"Orchard.MultiTenancy\""); -#line 100 +#line 99 testRunner.When("I go to \"Admin/MultiTenancy/Add\""); #line hidden TechTalk.SpecFlow.Table table7 = new TechTalk.SpecFlow.Table(new string[] { @@ -331,11 +329,11 @@ testRunner.When("I go to \"Admin/MultiTenancy/Add\""); table7.AddRow(new string[] { "RequestUrlHost", "scott.example.org"}); -#line 101 +#line 100 testRunner.And("I fill in", ((string)(null)), table7); -#line 105 +#line 104 testRunner.And("I hit \"Save\""); -#line 106 +#line 105 testRunner.And("I go to \"/Setup\" on host scott.example.org"); #line hidden TechTalk.SpecFlow.Table table8 = new TechTalk.SpecFlow.Table(new string[] { @@ -350,17 +348,17 @@ testRunner.And("I go to \"/Setup\" on host scott.example.org"); table8.AddRow(new string[] { "ConfirmPassword", "6655321"}); -#line 107 +#line 106 testRunner.And("I fill in", ((string)(null)), table8); -#line 112 +#line 111 testRunner.And("I hit \"Finish Setup\""); -#line 113 +#line 112 testRunner.And("I go to \"/Admin/MultiTenancy/Edit/Scott\" on host localhost"); -#line 114 +#line 113 testRunner.Then("I should see \"

    Edit Tenant

    \""); -#line 115 +#line 114 testRunner.And("I should see \"

    Scott

    \""); -#line 116 +#line 115 testRunner.And("I should not see \"Allow the tenant to set up the database\""); #line hidden testRunner.CollectScenarioErrors(); @@ -368,20 +366,18 @@ testRunner.And("I should not see \"Allow the tenant to set up the database\""); [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Default tenant cannot be disabled")] - [NUnit.Framework.IgnoreAttribute()] public virtual void DefaultTenantCannotBeDisabled() { - TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Default tenant cannot be disabled", new string[] { - "ignore"}); -#line 119 + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Default tenant cannot be disabled", ((string[])(null))); +#line 117 this.ScenarioSetup(scenarioInfo); -#line 120 +#line 118 testRunner.Given("I have installed Orchard"); -#line 121 +#line 119 testRunner.And("I have installed \"Orchard.MultiTenancy\""); -#line 122 +#line 120 testRunner.When("I go to \"Admin/MultiTenancy\""); -#line 123 +#line 121 testRunner.Then("I should not see \"tenant list"); -#line 175 +#line 172 testRunner.Then("I should see \"Name: Alpha\""); -#line 176 +#line 173 testRunner.And("I should see \"Request Url Host: example.org\""); #line hidden testRunner.CollectScenarioErrors(); diff --git a/src/Orchard.Specs/Orchard.Specs.csproj b/src/Orchard.Specs/Orchard.Specs.csproj index d073c9aa0..7b771b57f 100644 --- a/src/Orchard.Specs/Orchard.Specs.csproj +++ b/src/Orchard.Specs/Orchard.Specs.csproj @@ -220,6 +220,7 @@ Always + Designer Always From 27f046ca6022c2c711aca41451fc1585282e10b5 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 4 Dec 2010 23:02:12 -0800 Subject: [PATCH 16/18] Delete ASP.NET folder created by spec flow tests --HG-- branch : dev --- src/Orchard.Specs/Hosting/WebHost.cs | 50 +++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/src/Orchard.Specs/Hosting/WebHost.cs b/src/Orchard.Specs/Hosting/WebHost.cs index a601b83c3..aea2a4f50 100644 --- a/src/Orchard.Specs/Hosting/WebHost.cs +++ b/src/Orchard.Specs/Hosting/WebHost.cs @@ -1,5 +1,9 @@ using System; +using System.Diagnostics; +using System.Linq; using System.Reflection; +using System.Threading; +using System.Web; using System.Web.Hosting; using Orchard.Specs.Util; using Path = Bleroy.FluentPath.Path; @@ -10,6 +14,7 @@ namespace Orchard.Specs.Hosting { private WebHostAgent _webHostAgent; private Path _tempSite; private Path _orchardWebPath; + private Path _codeGenDir; public WebHost(Path orchardTemp) { _orchardTemp = orchardTemp; @@ -60,6 +65,17 @@ namespace Orchard.Specs.Hosting { _webHostAgent = (WebHostAgent)ApplicationHost.CreateApplicationHost(typeof(WebHostAgent), VirtualDirectory, PhysicalDirectory); + var shuttle = new Shuttle(); + Execute(() => { shuttle.CodeGenDir = HttpRuntime.CodegenDir; }); + + // ASP.NET folder seems to be always nested into an empty directory + _codeGenDir = shuttle.CodeGenDir; + _codeGenDir = _codeGenDir.Parent; + } + + [Serializable] + class Shuttle { + public string CodeGenDir; } public void Dispose() { @@ -71,10 +87,42 @@ namespace Orchard.Specs.Hosting { } public void Clean() { + // Try to delete temporary files for up to ~1.2 seconds. + for (int i = 0; i < 4; i++) { + Trace.WriteLine("Waiting 300msec before trying to delete temporary files"); + Thread.Sleep(300); + + if (TryDeleteTempFiles()) { + Trace.WriteLine("Successfully deleted all temporary files"); + break; + } + } + } + + private bool TryDeleteTempFiles() { + var result = true; + if (_codeGenDir != null && _codeGenDir.Exists) { + Trace.WriteLine(string.Format("Trying to delete temporary files at '{0}", _codeGenDir)); + try { + _codeGenDir.Delete(true); // <- clean as much as possible + } + catch(Exception e) { + Trace.WriteLine(string.Format("failure: '{0}", e)); + result = false; + } + } + + if (_tempSite != null && _tempSite.Exists) try { + Trace.WriteLine(string.Format("Trying to delete temporary files at '{0}", _tempSite)); _tempSite.Delete(true); // <- progressively clean as much as possible } - catch { } + catch (Exception e) { + Trace.WriteLine(string.Format("failure: '{0}", e)); + result = false; + } + + return result; } public void CopyExtension(string extensionFolder, string extensionName, ExtensionDeploymentOptions deploymentOptions) { From 8a9b41a3be675324cd68a3ffbf3077f53445be3b Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 4 Dec 2010 23:03:49 -0800 Subject: [PATCH 17/18] Fix command --HG-- branch : dev --- Orchard.proj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Orchard.proj b/Orchard.proj index ac22d41e1..baa1d2e7b 100644 --- a/Orchard.proj +++ b/Orchard.proj @@ -342,7 +342,7 @@ - + From 8a0f68bdcc0cce2c9b30fb643f59c364fa345e01 Mon Sep 17 00:00:00 2001 From: Nathan Heskew Date: Mon, 6 Dec 2010 11:15:43 -0800 Subject: [PATCH 18/18] Fixing the admin menu to not have the "New" group collapse if there is only one item in there --HG-- branch : dev --- src/Orchard.Web/Themes/TheAdmin/Views/Menu.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Orchard.Web/Themes/TheAdmin/Views/Menu.cshtml b/src/Orchard.Web/Themes/TheAdmin/Views/Menu.cshtml index 12ddff3ab..ef3d5abf2 100644 --- a/src/Orchard.Web/Themes/TheAdmin/Views/Menu.cshtml +++ b/src/Orchard.Web/Themes/TheAdmin/Views/Menu.cshtml @@ -31,7 +31,7 @@ var firstLevelTag = Tag(firstLevelMenuItem, "li"); @firstLevelTag.StartElement

    @sectionHeaderMarkup

    - if (secondLevelMenuItems.Count() > 1) { + if (secondLevelMenuItems.Count() > 1 || !firstLevelMenuItem.LinkToFirstChild) {