Adding some spec tests for the routeable part's slug prefix display in the editor (for blogs)

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-11-29 16:01:46 -08:00
parent ff8eceefc9
commit de949ccdfc
6 changed files with 240 additions and 134 deletions

View File

@@ -10,12 +10,18 @@ namespace Orchard.Specs.Bindings {
public class OrchardSiteFactory : BindingBase { public class OrchardSiteFactory : BindingBase {
[Given(@"I have installed Orchard")] [Given(@"I have installed Orchard")]
public void GivenIHaveInstalledOrchard() { public void GivenIHaveInstalledOrchard() {
GivenIHaveInstalledOrchard("/");
}
[Given(@"I have installed Orchard at ""(.*)\""")]
public void GivenIHaveInstalledOrchard(string virtualDirectory) {
var webApp = Binding<WebAppHosting>(); var webApp = Binding<WebAppHosting>();
webApp.GivenIHaveACleanSiteWith(TableData( webApp.GivenIHaveACleanSiteWith(TableData(
new { extension = "module", names = "Orchard.Setup, Orchard.Pages, Orchard.Blogs, Orchard.Messaging, Orchard.Modules, Orchard.Packaging, Orchard.PublishLater, Orchard.Themes, Orchard.Scripting, Orchard.Widgets, Orchard.Users, Orchard.Roles, Orchard.Comments, Orchard.jQuery, Orchard.Tags, TinyMce" }, new { extension = "module", names = "Orchard.Setup, Orchard.Pages, Orchard.Blogs, Orchard.Messaging, Orchard.Modules, Orchard.Packaging, Orchard.PublishLater, Orchard.Themes, Orchard.Scripting, Orchard.Widgets, Orchard.Users, Orchard.Roles, Orchard.Comments, Orchard.jQuery, Orchard.Tags, TinyMce" },
new { extension = "core", names = "Common, Dashboard, Feeds, HomePage, Navigation, Contents, Routable, Scheduling, Settings, Shapes, XmlRpc" }, new { extension = "core", names = "Common, Dashboard, Feeds, HomePage, Navigation, Contents, Routable, Scheduling, Settings, Shapes, XmlRpc" },
new { extension = "theme", names = "SafeMode, TheAdmin, TheThemeMachine" })); new { extension = "theme", names = "SafeMode, TheAdmin, TheThemeMachine" }),
virtualDirectory);
webApp.WhenIGoTo("Setup"); webApp.WhenIGoTo("Setup");

View File

@@ -60,8 +60,8 @@ namespace Orchard.Specs.Bindings {
} }
[Given(@"I have a clean site")] [Given(@"I have a clean site")]
public void GivenIHaveACleanSite() { public void GivenIHaveACleanSite(string virtualDirectory = "/") {
GivenIHaveACleanSiteBasedOn("Orchard.Web"); GivenIHaveACleanSiteBasedOn("Orchard.Web", virtualDirectory);
} }
[Given(@"I have chosen to deploy modules as source files only")] [Given(@"I have chosen to deploy modules as source files only")]
@@ -71,8 +71,13 @@ namespace Orchard.Specs.Bindings {
[Given(@"I have a clean site based on (.*)")] [Given(@"I have a clean site based on (.*)")]
public void GivenIHaveACleanSiteBasedOn(string siteFolder) { public void GivenIHaveACleanSiteBasedOn(string siteFolder) {
GivenIHaveACleanSiteBasedOn(siteFolder, "/");
}
[Given(@"I have a clean site based on (.*) at ""(.*)\""")]
public void GivenIHaveACleanSiteBasedOn(string siteFolder, string virtualDirectory) {
_webHost = new WebHost(_orchardTemp); _webHost = new WebHost(_orchardTemp);
Host.Initialize(siteFolder, "/"); Host.Initialize(siteFolder, virtualDirectory ?? "/");
var shuttle = new Shuttle(); var shuttle = new Shuttle();
Host.Execute(() => { Host.Execute(() => {
log4net.Config.BasicConfigurator.Configure(new CastleAppender()); log4net.Config.BasicConfigurator.Configure(new CastleAppender());
@@ -124,8 +129,8 @@ namespace Orchard.Specs.Bindings {
} }
[Given(@"I have a clean site with")] [Given(@"I have a clean site with")]
public void GivenIHaveACleanSiteWith(Table table) { public void GivenIHaveACleanSiteWith(Table table, string virtualDirectory = "/") {
GivenIHaveACleanSite(); GivenIHaveACleanSite(virtualDirectory);
foreach (var row in table.Rows) { foreach (var row in table.Rows) {
foreach (var name in row["names"].Split(',').Select(x => x.Trim())) { foreach (var name in row["names"].Split(',').Select(x => x.Trim())) {
switch (row["extension"]) { switch (row["extension"]) {

View File

@@ -126,3 +126,25 @@ Scenario: Enabling remote blog publishing inserts the appropriate metaweblogapi
Then the content type should be "\btext/xml\b" Then the content type should be "\btext/xml\b"
And I should see "<manifest xmlns="http\://schemas\.microsoft\.com/wlw/manifest/weblog">" And I should see "<manifest xmlns="http\://schemas\.microsoft\.com/wlw/manifest/weblog">"
And I should see "<clientType>Metaweblog</clientType>" And I should see "<clientType>Metaweblog</clientType>"
Scenario: The virtual path of my installation when not at the root is reflected in the URL example for the slug field when creating a blog or blog post
Given I have installed Orchard at "/OrchardLocal"
When I go to "admin/blogs/create"
Then I should see "<span>http\://localhost/OrchardLocal/</span>"
When I fill in
| name | value |
| Routable.Title | My Blog |
And I hit "Save"
And I go to "admin/blogs/my-blog/posts/create"
Then I should see "<span>http\://localhost/OrchardLocal/my-blog/</span>"
Scenario: The virtual path of my installation when at the root is reflected in the URL example for the slug field when creating a blog or blog post
Given I have installed Orchard at "/"
When I go to "admin/blogs/create"
Then I should see "<span>http\://localhost/</span>"
When I fill in
| name | value |
| Routable.Title | My Blog |
And I hit "Save"
And I go to "admin/blogs/my-blog/posts/create"
Then I should see "<span>http\://localhost/my-blog/</span>"

View File

@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by SpecFlow (http://www.specflow.org/). // This code was generated by SpecFlow (http://www.specflow.org/).
// SpecFlow Version:1.3.2.0 // SpecFlow Version:1.4.0.0
// Runtime Version:4.0.30319.1 // Runtime Version:4.0.30319.1
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
@@ -14,7 +14,7 @@ namespace Orchard.Specs
using TechTalk.SpecFlow; using TechTalk.SpecFlow;
[System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.3.2.0")] [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.4.0.0")]
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[NUnit.Framework.TestFixtureAttribute()] [NUnit.Framework.TestFixtureAttribute()]
[NUnit.Framework.DescriptionAttribute("Blog")] [NUnit.Framework.DescriptionAttribute("Blog")]
@@ -31,7 +31,7 @@ namespace Orchard.Specs
{ {
testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(); testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner();
TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Blog", "In order to add blogs to my site\r\nAs an author\r\nI want to create blogs and create" + TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Blog", "In order to add blogs to my site\r\nAs an author\r\nI want to create blogs and create" +
", publish and edit blog posts", ((string[])(null))); ", publish and edit blog posts", GenerationTargetLanguage.CSharp, ((string[])(null)));
testRunner.OnFeatureStart(featureInfo); testRunner.OnFeatureStart(featureInfo);
} }
@@ -389,6 +389,74 @@ testRunner.And("I should see \"<manifest xmlns=\"http\\://schemas\\.microsoft\\.
"g\">\""); "g\">\"");
#line 128 #line 128
testRunner.And("I should see \"<clientType>Metaweblog</clientType>\""); testRunner.And("I should see \"<clientType>Metaweblog</clientType>\"");
#line hidden
testRunner.CollectScenarioErrors();
}
[NUnit.Framework.TestAttribute()]
[NUnit.Framework.DescriptionAttribute("The virtual path of my installation when not at the root is reflected in the URL " +
"example for the slug field when creating a blog or blog post")]
public virtual void TheVirtualPathOfMyInstallationWhenNotAtTheRootIsReflectedInTheURLExampleForTheSlugFieldWhenCreatingABlogOrBlogPost()
{
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("The virtual path of my installation when not at the root is reflected in the URL " +
"example for the slug field when creating a blog or blog post", ((string[])(null)));
#line 130
this.ScenarioSetup(scenarioInfo);
#line 131
testRunner.Given("I have installed Orchard at \"/OrchardLocal\"");
#line 132
testRunner.When("I go to \"admin/blogs/create\"");
#line 133
testRunner.Then("I should see \"<span>http\\://localhost/OrchardLocal/</span>\"");
#line hidden
TechTalk.SpecFlow.Table table13 = new TechTalk.SpecFlow.Table(new string[] {
"name",
"value"});
table13.AddRow(new string[] {
"Routable.Title",
"My Blog"});
#line 134
testRunner.When("I fill in", ((string)(null)), table13);
#line 137
testRunner.And("I hit \"Save\"");
#line 138
testRunner.And("I go to \"admin/blogs/my-blog/posts/create\"");
#line 139
testRunner.Then("I should see \"<span>http\\://localhost/OrchardLocal/my-blog/</span>\"");
#line hidden
testRunner.CollectScenarioErrors();
}
[NUnit.Framework.TestAttribute()]
[NUnit.Framework.DescriptionAttribute("The virtual path of my installation when at the root is reflected in the URL exam" +
"ple for the slug field when creating a blog or blog post")]
public virtual void TheVirtualPathOfMyInstallationWhenAtTheRootIsReflectedInTheURLExampleForTheSlugFieldWhenCreatingABlogOrBlogPost()
{
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("The virtual path of my installation when at the root is reflected in the URL exam" +
"ple for the slug field when creating a blog or blog post", ((string[])(null)));
#line 141
this.ScenarioSetup(scenarioInfo);
#line 142
testRunner.Given("I have installed Orchard at \"/\"");
#line 143
testRunner.When("I go to \"admin/blogs/create\"");
#line 144
testRunner.Then("I should see \"<span>http\\://localhost/</span>\"");
#line hidden
TechTalk.SpecFlow.Table table14 = new TechTalk.SpecFlow.Table(new string[] {
"name",
"value"});
table14.AddRow(new string[] {
"Routable.Title",
"My Blog"});
#line 145
testRunner.When("I fill in", ((string)(null)), table14);
#line 148
testRunner.And("I hit \"Save\"");
#line 149
testRunner.And("I go to \"admin/blogs/my-blog/posts/create\"");
#line 150
testRunner.Then("I should see \"<span>http\\://localhost/my-blog/</span>\"");
#line hidden #line hidden
testRunner.CollectScenarioErrors(); testRunner.CollectScenarioErrors();
} }

View File

@@ -6,8 +6,6 @@ using System.Linq;
using System.Text; using System.Text;
using System.Web; using System.Web;
using System.Web.Hosting; using System.Web.Hosting;
using HtmlAgilityPack;
using Orchard.Commands;
using Orchard.Specs.Util; using Orchard.Specs.Util;
namespace Orchard.Specs.Hosting { namespace Orchard.Specs.Hosting {
@@ -16,12 +14,13 @@ namespace Orchard.Specs.Hosting {
var physicalPath = Bleroy.FluentPath.Path.Get(webHost.PhysicalDirectory); var physicalPath = Bleroy.FluentPath.Path.Get(webHost.PhysicalDirectory);
urlPath = StripVDir(urlPath, webHost.VirtualDirectory);
var details = new RequestDetails { var details = new RequestDetails {
HostName = webHost.HostName, HostName = webHost.HostName,
UrlPath = urlPath, UrlPath = urlPath,
Page = physicalPath Page = physicalPath
.Combine(urlPath.TrimStart('/', '\\')) .Combine(urlPath.TrimStart('/', '\\'))
.GetRelativePath(physicalPath), .GetRelativePath(physicalPath)
}; };
if (!string.IsNullOrEmpty(webHost.Cookies)) { if (!string.IsNullOrEmpty(webHost.Cookies)) {
@@ -52,6 +51,12 @@ namespace Orchard.Specs.Hosting {
return details; return details;
} }
private static string StripVDir(string urlPath, string virtualDirectory) {
return urlPath.StartsWith(virtualDirectory, StringComparison.OrdinalIgnoreCase)
? urlPath.Substring(virtualDirectory.Length)
: urlPath;
}
public static RequestDetails SendRequest(this WebHost webHost, string urlPath) { public static RequestDetails SendRequest(this WebHost webHost, string urlPath) {
return webHost.SendRequest(urlPath, null); return webHost.SendRequest(urlPath, null);
} }

View File

@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by SpecFlow (http://www.specflow.org/). // This code was generated by SpecFlow (http://www.specflow.org/).
// SpecFlow Version:1.3.2.0 // SpecFlow Version:1.4.0.0
// Runtime Version:4.0.30319.1 // Runtime Version:4.0.30319.1
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
@@ -14,7 +14,7 @@ namespace Orchard.Specs
using TechTalk.SpecFlow; using TechTalk.SpecFlow;
[System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.3.2.0")] [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.4.0.0")]
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[NUnit.Framework.TestFixtureAttribute()] [NUnit.Framework.TestFixtureAttribute()]
[NUnit.Framework.DescriptionAttribute("Web Hosting")] [NUnit.Framework.DescriptionAttribute("Web Hosting")]
@@ -31,7 +31,7 @@ namespace Orchard.Specs
{ {
testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(); testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner();
TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Web Hosting", "In order to test orchard\r\nAs an integration runner\r\nI want to verify basic hostin" + TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Web Hosting", "In order to test orchard\r\nAs an integration runner\r\nI want to verify basic hostin" +
"g is working", ((string[])(null))); "g is working", GenerationTargetLanguage.CSharp, ((string[])(null)));
testRunner.OnFeatureStart(featureInfo); testRunner.OnFeatureStart(featureInfo);
} }