mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-12-03 12:03:51 +08:00
Fix SpecFlow test
When a new module is installed in the host app, explicitly call "ReloadExtensions" on the host so that the new module is activated. We need this because some SpecFlow binding talk directly to the host through remoting, whereas in the real web scenarios, all comunication is done through "BeingRequest" which is the guy taking care of reloading modules when they have changed on disk. --HG-- branch : dev
This commit is contained in:
@@ -32,7 +32,12 @@ namespace Orchard.Specs.Bindings {
|
||||
|
||||
[Given(@"I have installed ""(.*)\""")]
|
||||
public void GivenIHaveInstalled(string name) {
|
||||
Binding<WebAppHosting>().GivenIHaveModule(name);
|
||||
var webApp = Binding<WebAppHosting>();
|
||||
webApp.GivenIHaveModule(name);
|
||||
webApp.Host.Execute(() => {
|
||||
MvcApplication.ReloadExtensions();
|
||||
});
|
||||
|
||||
GivenIHaveEnabled(name);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using Autofac;
|
||||
using Autofac.Integration.Web;
|
||||
using Orchard.Environment;
|
||||
using Orchard.Environment.Configuration;
|
||||
|
||||
@@ -20,7 +18,6 @@ namespace Orchard.Specs.Hosting.Orchard.Web {
|
||||
|
||||
var route = RouteTable.Routes.MapRoute("foo", "hello-world", new { controller = "Home", action = "Index" });
|
||||
route.RouteHandler = new HelloYetAgainHandler();
|
||||
|
||||
}
|
||||
|
||||
protected void Application_BeginRequest() {
|
||||
@@ -43,6 +40,10 @@ namespace Orchard.Specs.Hosting.Orchard.Web {
|
||||
get { return _host; }
|
||||
}
|
||||
|
||||
public static void ReloadExtensions() {
|
||||
_host.ReloadExtensions();
|
||||
}
|
||||
|
||||
public static IStandaloneEnvironment CreateStandaloneEnvironment(string name) {
|
||||
var settings = _hostContainer.Resolve<IShellSettingsManager>().LoadSettings().SingleOrDefault(x => x.Name == name);
|
||||
return Host.CreateStandaloneEnvironment(settings);
|
||||
|
||||
@@ -22,4 +22,3 @@ Scenario: Creating a folder
|
||||
Then I should see "Manage Media Folders"
|
||||
And I should see "Hello World"
|
||||
And the status should be 200 OK
|
||||
|
||||
|
||||
8
src/Orchard.Specs/Media.feature.cs
generated
8
src/Orchard.Specs/Media.feature.cs
generated
@@ -1,18 +1,21 @@
|
||||
// ------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by SpecFlow (http://www.specflow.org/).
|
||||
// SpecFlow Version:1.2.0.0
|
||||
// Runtime Version:2.0.50727.4927
|
||||
// SpecFlow Version:1.3.2.0
|
||||
// Runtime Version:4.0.30319.1
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
// ------------------------------------------------------------------------------
|
||||
#region Designer generated code
|
||||
namespace Orchard.Specs
|
||||
{
|
||||
using TechTalk.SpecFlow;
|
||||
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.3.2.0")]
|
||||
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[NUnit.Framework.TestFixtureAttribute()]
|
||||
[NUnit.Framework.DescriptionAttribute("Media management")]
|
||||
public partial class MediaManagementFeature
|
||||
@@ -108,3 +111,4 @@ this.ScenarioSetup(scenarioInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -66,6 +66,10 @@ namespace Orchard.Environment {
|
||||
BuildCurrent();
|
||||
}
|
||||
|
||||
void IOrchardHost.ReloadExtensions() {
|
||||
_current = null;
|
||||
BuildCurrent();
|
||||
}
|
||||
|
||||
void IOrchardHost.BeginRequest() {
|
||||
Logger.Debug("BeginRequest");
|
||||
|
||||
@@ -8,6 +8,12 @@ namespace Orchard.Environment {
|
||||
/// </summary>
|
||||
void Initialize();
|
||||
|
||||
/// <summary>
|
||||
/// Called externally when there is explicit knowledge that the list of installed
|
||||
/// modules/extensions has changed, and they need to be reloaded.
|
||||
/// </summary>
|
||||
void ReloadExtensions();
|
||||
|
||||
/// <summary>
|
||||
/// Called each time a request begins to offer a just-in-time reinitialization point
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user