From 6e90698c8c48c35f9b690c36b4acab1fdb3fdb88 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Mon, 19 May 2014 14:27:30 -0700 Subject: [PATCH 1/9] Fixing comments specflow tests --- src/Orchard.Specs/Comments.feature | 19 ++-- src/Orchard.Specs/Comments.feature.cs | 88 +++++++------------ .../Filters/OutputCacheFilter.cs | 20 ++--- 3 files changed, 45 insertions(+), 82 deletions(-) diff --git a/src/Orchard.Specs/Comments.feature b/src/Orchard.Specs/Comments.feature index 6051faccc..7c27734a3 100644 --- a/src/Orchard.Specs/Comments.feature +++ b/src/Orchard.Specs/Comments.feature @@ -43,21 +43,14 @@ Scenario: HTML markup in any given comment is encoded Then I should see "This is<br id="bad-anon-br" />a <a href" And I should not see "
" -Scenario: Moderated comments are not displayed - Given I have installed Orchard - When I go to "admin/blogs/create" + # Moderated comments are not displayed + When I go to "users/account/logon" And I fill in | name | value | - | Title.Title | My Blog | - And I hit "Save" - And I go to "admin/blogs" - And I follow "My Blog" - And I follow "New Post" where class name has "primaryAction" - And I fill in - | name | value | - | Title.Title | My Post | - | Body.Text | Hi there. | - And I hit "Publish Now" + | userNameOrEmail | admin | + | password | 6655321 | + And I hit "Sign In" + And I am redirected And I go to "admin/settings/comments" And I fill in | name | value | diff --git a/src/Orchard.Specs/Comments.feature.cs b/src/Orchard.Specs/Comments.feature.cs index bef778753..268618841 100644 --- a/src/Orchard.Specs/Comments.feature.cs +++ b/src/Orchard.Specs/Comments.feature.cs @@ -154,94 +154,66 @@ this.ScenarioSetup(scenarioInfo); testRunner.Then("I should see \"This is<br id="bad-anon-br" />a <a href\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); #line 44 testRunner.And("I should not see \"
\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); -#line hidden - this.ScenarioCleanup(); - } - - [NUnit.Framework.TestAttribute()] - [NUnit.Framework.DescriptionAttribute("Moderated comments are not displayed")] - public virtual void ModeratedCommentsAreNotDisplayed() - { - TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Moderated comments are not displayed", ((string[])(null))); -#line 46 -this.ScenarioSetup(scenarioInfo); #line 47 - testRunner.Given("I have installed Orchard", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); -#line 48 - testRunner.When("I go to \"admin/blogs/create\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); + testRunner.When("I go to \"users/account/logon\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); #line hidden TechTalk.SpecFlow.Table table5 = new TechTalk.SpecFlow.Table(new string[] { "name", "value"}); table5.AddRow(new string[] { - "Title.Title", - "My Blog"}); -#line 49 + "userNameOrEmail", + "admin"}); + table5.AddRow(new string[] { + "password", + "6655321"}); +#line 48 testRunner.And("I fill in", ((string)(null)), table5, "And "); #line 52 - testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); + testRunner.And("I hit \"Sign In\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line 53 - testRunner.And("I go to \"admin/blogs\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); + testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line 54 - testRunner.And("I follow \"My Blog\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); -#line 55 - testRunner.And("I follow \"New Post\" where class name has \"primaryAction\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); + testRunner.And("I go to \"admin/settings/comments\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line hidden TechTalk.SpecFlow.Table table6 = new TechTalk.SpecFlow.Table(new string[] { "name", "value"}); table6.AddRow(new string[] { - "Title.Title", - "My Post"}); - table6.AddRow(new string[] { - "Body.Text", - "Hi there."}); -#line 56 - testRunner.And("I fill in", ((string)(null)), table6, "And "); + "CommentSettings.ModerateComments", + "true"}); +#line 55 + testRunner.And("I fill in", ((string)(null)), table6, "And "); +#line 58 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 59 + testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line 60 - testRunner.And("I hit \"Publish Now\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); + testRunner.Then("I should see \"Settings updated\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); #line 61 - testRunner.And("I go to \"admin/settings/comments\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); + testRunner.When("I go to \"users/account/logoff\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 62 + testRunner.And("I go to \"my-blog/my-post\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line hidden TechTalk.SpecFlow.Table table7 = new TechTalk.SpecFlow.Table(new string[] { "name", "value"}); table7.AddRow(new string[] { - "CommentSettings.ModerateComments", - "true"}); -#line 62 - testRunner.And("I fill in", ((string)(null)), table7, "And "); -#line 65 - testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); -#line 66 - testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); -#line 67 - testRunner.Then("I should see \"Settings updated\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); -#line 68 - testRunner.When("I go to \"users/account/logoff\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); -#line 69 - testRunner.And("I go to \"my-blog/my-post\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); -#line hidden - TechTalk.SpecFlow.Table table8 = new TechTalk.SpecFlow.Table(new string[] { - "name", - "value"}); - table8.AddRow(new string[] { "Comments.Author", "Bill"}); - table8.AddRow(new string[] { + table7.AddRow(new string[] { "Comments.CommentText", "This is a moderated comment."}); -#line 70 - testRunner.And("I fill in", ((string)(null)), table8, "And "); -#line 74 +#line 63 + testRunner.And("I fill in", ((string)(null)), table7, "And "); +#line 67 testRunner.And("I hit \"Submit Comment\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); -#line 75 +#line 68 testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); -#line 77 +#line 70 testRunner.And("I go to \"my-blog/my-post\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); -#line 78 +#line 71 testRunner.Then("I should see \"Hi there\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); -#line 79 +#line 72 testRunner.And("I should not see \"This is a moderated comment\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line hidden this.ScenarioCleanup(); diff --git a/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs b/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs index 1142909d0..a48d5bad1 100644 --- a/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs +++ b/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs @@ -95,6 +95,8 @@ namespace Orchard.OutputCache.Filters { var controllerAttributes = filterContext.ActionDescriptor.ControllerDescriptor.GetCustomAttributes(typeof(OutputCacheAttribute), true); var outputCacheAttribute = actionAttributes.Concat(controllerAttributes).Cast().FirstOrDefault(); + _workContext = _workContextAccessor.GetContext(); + if (outputCacheAttribute != null) { if (outputCacheAttribute.Duration <= 0 || outputCacheAttribute.NoStore) { Logger.Debug("Request ignored based on OutputCache attribute"); @@ -128,8 +130,6 @@ namespace Orchard.OutputCache.Filters { return; } - _workContext = _workContextAccessor.GetContext(); - // don't return any cached content, or cache any content, if the user is authenticated if (_workContext.CurrentUser != null) { Logger.Debug("Request ignored on Authenticated user"); @@ -290,19 +290,14 @@ namespace Orchard.OutputCache.Filters { } public void OnActionExecuted(ActionExecutedContext filterContext) { - // this means the cache module is not applied in this context - if (_workContext == null) { - return; - } - + // handle redirections _transformRedirect = TransformRedirect(filterContext); } public void OnResultExecuted(ResultExecutedContext filterContext) { - // this means the cache module is not applied in this context - if (_workContext == null) { + if (AdminFilter.IsApplied(new RequestContext(filterContext.HttpContext, new RouteData()))) { return; } @@ -461,6 +456,10 @@ namespace Orchard.OutputCache.Filters { throw new ArgumentNullException(); } + if (AdminFilter.IsApplied(new RequestContext(filterContext.HttpContext, new RouteData()))) { + return false; + } + var redirectResult = filterContext.Result as RedirectResult; // status code can't be tested at this point, so test the result type instead @@ -475,8 +474,7 @@ namespace Orchard.OutputCache.Filters { if (!VirtualPathUtility.IsAbsolute(redirectUrl)) { var applicationRoot = new UrlHelper(filterContext.HttpContext.Request.RequestContext).MakeAbsolute("/"); if (redirectUrl.StartsWith(applicationRoot, StringComparison.OrdinalIgnoreCase)) { - redirectUrl = "~/" + redirectUrl.Substring(applicationRoot.Length); - redirectUrl = VirtualPathUtility.ToAbsolute(redirectUrl); + redirectUrl = redirectUrl.Substring(applicationRoot.Length); } } From 6aea57b2ca03bfa935373c8da35606cd1b7acfaa Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Mon, 19 May 2014 14:38:49 -0700 Subject: [PATCH 2/9] Fixing DateTimeField specflow tests --- src/Orchard.Specs/DateTime.feature | 42 ++++++++++++------------- src/Orchard.Specs/DateTime.feature.cs | 44 +++++++++++++-------------- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/Orchard.Specs/DateTime.feature b/src/Orchard.Specs/DateTime.feature index 29f070ee6..de1f61881 100644 --- a/src/Orchard.Specs/DateTime.feature +++ b/src/Orchard.Specs/DateTime.feature @@ -36,20 +36,20 @@ Scenario: Creating and using Date fields Then I should see "Date of the event" When I fill in | name | value | - | Event.EventDate.Date | 31/01/2012 | - | Event.EventDate.Time | 12:00 AM | + | Event.EventDate.Editor.Date | 31/01/2012 | + | Event.EventDate.Editor.Time | 12:00 AM | And I hit "Save" - Then I should see "Date of the event is an invalid date and time" + Then I should see "Date of the event could not be parsed as a valid date and time" # Creating an Event content item When I go to "Admin/Contents/Create/Event" Then I should see "Date of the event" When I fill in | name | value | - | Event.EventDate.Date | 01/31/2012 | + | Event.EventDate.Editor.Date | 01/31/2012 | And I fill in | name | value | - | Event.EventDate.Time | 12:00 AM | + | Event.EventDate.Editor.Time | 12:00 AM | And I hit "Save" And I am redirected Then I should see "Your Event has been created." @@ -73,8 +73,8 @@ Scenario: Creating and using Date fields | Fields[0].DateTimeFieldSettings.Display | DateOnly | And I hit "Save" And I go to "Admin/Contents/Create/Event" - Then I should see "Event.EventDate.Date" - And I should not see "Event.EventDate.Time" + Then I should see "Event.EventDate.Editor.Date" + And I should not see "Event.EventDate.Editor.Time" # Display = TimeOnly When I go to "Admin/ContentTypes/Edit/Event" @@ -83,8 +83,8 @@ Scenario: Creating and using Date fields | Fields[0].DateTimeFieldSettings.Display | TimeOnly | And I hit "Save" And I go to "Admin/Contents/Create/Event" - Then I should see "Event.EventDate.Time" - And I should not see "Event.EventDate.Date" + Then I should see "Event.EventDate.Editor.Time" + And I should not see "Event.EventDate.Editor.Date" # Required & Date and Time When I go to "Admin/ContentTypes/Edit/Event" @@ -94,24 +94,24 @@ Scenario: Creating and using Date fields | Fields[0].DateTimeFieldSettings.Required | true | And I hit "Save" And I go to "Admin/Contents/Create/Event" - Then I should see "Event.EventDate.Date" + Then I should see "Event.EventDate.Editor.Date" When I fill in | name | value | - | Event.EventDate.Date | 01/31/2012 | - | Event.EventDate.Time | 12:00 AM | + | Event.EventDate.Editor.Date | 01/31/2012 | + | Event.EventDate.Editor.Time | 12:00 AM | And I hit "Save" And I am redirected Then I should see "Your Event has been created." When I go to "Admin/Contents/Create/Event" And I fill in | name | value | - | Event.EventDate.Date | 01/31/2012 | + | Event.EventDate.Editor.Date | 01/31/2012 | And I hit "Save" Then I should see "Date of the event is required." When I go to "Admin/Contents/Create/Event" And I fill in | name | value | - | Event.EventDate.Time | 12:00 AM | + | Event.EventDate.Editor.Time | 12:00 AM | And I hit "Save" Then I should see "Date of the event is required." @@ -123,7 +123,7 @@ Scenario: Creating and using Date fields | Fields[0].DateTimeFieldSettings.Required | true | And I hit "Save" And I go to "Admin/Contents/Create/Event" - Then I should see "Event.EventDate.Date" + Then I should see "Event.EventDate.Editor.Date" When I hit "Save" Then I should see "Date of the event is required." @@ -135,7 +135,7 @@ Scenario: Creating and using Date fields | Fields[0].DateTimeFieldSettings.Required | true | And I hit "Save" And I go to "Admin/Contents/Create/Event" - Then I should see "Event.EventDate.Date" + Then I should see "Event.EventDate.Editor.Date" When I hit "Save" Then I should see "Date of the event is required." @@ -179,15 +179,15 @@ Scenario: Creating and using date time fields in another culture When I go to "Admin/Contents/Create/Event" And I fill in | name | value | - | Event.EventDate.Date | 01/31/2012 | - | Event.EventDate.Time | 12:00 AM | + | Event.EventDate.Editor.Date | 01/31/2012 | + | Event.EventDate.Editor.Time | 12:00 AM | And I hit "Save" - Then I should see "Date of the event is an invalid date and time" + Then I should see "Date of the event could not be parsed as a valid date and time" When I go to "Admin/Contents/Create/Event" And I fill in | name | value | - | Event.EventDate.Date | 31/01/2012 | - | Event.EventDate.Time | 18:00 | + | Event.EventDate.Editor.Date | 31/01/2012 | + | Event.EventDate.Editor.Time | 18:00 | And I hit "Save" And I am redirected Then I should see "Your Event has been created." diff --git a/src/Orchard.Specs/DateTime.feature.cs b/src/Orchard.Specs/DateTime.feature.cs index 846ca2ab4..635470931 100644 --- a/src/Orchard.Specs/DateTime.feature.cs +++ b/src/Orchard.Specs/DateTime.feature.cs @@ -3,7 +3,7 @@ // This code was generated by SpecFlow (http://www.specflow.org/). // SpecFlow Version:1.9.0.77 // SpecFlow Generator Version:1.9.0.0 -// Runtime Version:4.0.30319.33440 +// Runtime Version:4.0.30319.34014 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -134,17 +134,17 @@ this.ScenarioSetup(scenarioInfo); "name", "value"}); table3.AddRow(new string[] { - "Event.EventDate.Date", + "Event.EventDate.Editor.Date", "31/01/2012"}); table3.AddRow(new string[] { - "Event.EventDate.Time", + "Event.EventDate.Editor.Time", "12:00 AM"}); #line 37 testRunner.When("I fill in", ((string)(null)), table3, "When "); #line 41 testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line 42 - testRunner.Then("I should see \"Date of the event is an invalid date and time\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); + testRunner.Then("I should see \"Date of the event could not be parsed as a valid date and time\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); #line 45 testRunner.When("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); #line 46 @@ -154,7 +154,7 @@ this.ScenarioSetup(scenarioInfo); "name", "value"}); table4.AddRow(new string[] { - "Event.EventDate.Date", + "Event.EventDate.Editor.Date", "01/31/2012"}); #line 47 testRunner.When("I fill in", ((string)(null)), table4, "When "); @@ -163,7 +163,7 @@ this.ScenarioSetup(scenarioInfo); "name", "value"}); table5.AddRow(new string[] { - "Event.EventDate.Time", + "Event.EventDate.Editor.Time", "12:00 AM"}); #line 50 testRunner.And("I fill in", ((string)(null)), table5, "And "); @@ -212,9 +212,9 @@ this.ScenarioSetup(scenarioInfo); #line 75 testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line 76 - testRunner.Then("I should see \"Event.EventDate.Date\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); + testRunner.Then("I should see \"Event.EventDate.Editor.Date\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); #line 77 - testRunner.And("I should not see \"Event.EventDate.Time\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); + testRunner.And("I should not see \"Event.EventDate.Editor.Time\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line 80 testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); #line hidden @@ -231,9 +231,9 @@ this.ScenarioSetup(scenarioInfo); #line 85 testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line 86 - testRunner.Then("I should see \"Event.EventDate.Time\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); + testRunner.Then("I should see \"Event.EventDate.Editor.Time\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); #line 87 - testRunner.And("I should not see \"Event.EventDate.Date\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); + testRunner.And("I should not see \"Event.EventDate.Editor.Date\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line 90 testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); #line hidden @@ -253,16 +253,16 @@ this.ScenarioSetup(scenarioInfo); #line 96 testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line 97 - testRunner.Then("I should see \"Event.EventDate.Date\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); + testRunner.Then("I should see \"Event.EventDate.Editor.Date\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); #line hidden TechTalk.SpecFlow.Table table10 = new TechTalk.SpecFlow.Table(new string[] { "name", "value"}); table10.AddRow(new string[] { - "Event.EventDate.Date", + "Event.EventDate.Editor.Date", "01/31/2012"}); table10.AddRow(new string[] { - "Event.EventDate.Time", + "Event.EventDate.Editor.Time", "12:00 AM"}); #line 98 testRunner.When("I fill in", ((string)(null)), table10, "When "); @@ -279,7 +279,7 @@ this.ScenarioSetup(scenarioInfo); "name", "value"}); table11.AddRow(new string[] { - "Event.EventDate.Date", + "Event.EventDate.Editor.Date", "01/31/2012"}); #line 106 testRunner.And("I fill in", ((string)(null)), table11, "And "); @@ -294,7 +294,7 @@ this.ScenarioSetup(scenarioInfo); "name", "value"}); table12.AddRow(new string[] { - "Event.EventDate.Time", + "Event.EventDate.Editor.Time", "12:00 AM"}); #line 112 testRunner.And("I fill in", ((string)(null)), table12, "And "); @@ -321,7 +321,7 @@ this.ScenarioSetup(scenarioInfo); #line 125 testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line 126 - testRunner.Then("I should see \"Event.EventDate.Date\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); + testRunner.Then("I should see \"Event.EventDate.Editor.Date\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); #line 127 testRunner.When("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); #line 128 @@ -345,7 +345,7 @@ this.ScenarioSetup(scenarioInfo); #line 137 testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line 138 - testRunner.Then("I should see \"Event.EventDate.Date\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); + testRunner.Then("I should see \"Event.EventDate.Editor.Date\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); #line 139 testRunner.When("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); #line 140 @@ -442,17 +442,17 @@ this.ScenarioSetup(scenarioInfo); "name", "value"}); table18.AddRow(new string[] { - "Event.EventDate.Date", + "Event.EventDate.Editor.Date", "01/31/2012"}); table18.AddRow(new string[] { - "Event.EventDate.Time", + "Event.EventDate.Editor.Time", "12:00 AM"}); #line 180 testRunner.And("I fill in", ((string)(null)), table18, "And "); #line 184 testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line 185 - testRunner.Then("I should see \"Date of the event is an invalid date and time\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); + testRunner.Then("I should see \"Date of the event could not be parsed as a valid date and time\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); #line 186 testRunner.When("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); #line hidden @@ -460,10 +460,10 @@ this.ScenarioSetup(scenarioInfo); "name", "value"}); table19.AddRow(new string[] { - "Event.EventDate.Date", + "Event.EventDate.Editor.Date", "31/01/2012"}); table19.AddRow(new string[] { - "Event.EventDate.Time", + "Event.EventDate.Editor.Time", "18:00"}); #line 187 testRunner.And("I fill in", ((string)(null)), table19, "And "); From 34410dd4297dcbee0371584eca47aad75d3b08b4 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Mon, 19 May 2014 15:30:08 -0700 Subject: [PATCH 3/9] Fixing Widgets specflow tests --- .../Hosting/RequestExtensions.cs | 2 +- src/Orchard.Specs/Widgets.feature | 3 +- src/Orchard.Specs/Widgets.feature.cs | 90 ++++++++++--------- 3 files changed, 49 insertions(+), 46 deletions(-) diff --git a/src/Orchard.Specs/Hosting/RequestExtensions.cs b/src/Orchard.Specs/Hosting/RequestExtensions.cs index 2c3e76254..4d0fe6a16 100644 --- a/src/Orchard.Specs/Hosting/RequestExtensions.cs +++ b/src/Orchard.Specs/Hosting/RequestExtensions.cs @@ -181,7 +181,7 @@ namespace Orchard.Specs.Hosting { } public override void SendUnknownResponseHeader(string name, string value) { - _details.ResponseHeaders.Add(name, value); + _details.ResponseHeaders[name] = value; base.SendUnknownResponseHeader(name, value); } diff --git a/src/Orchard.Specs/Widgets.feature b/src/Orchard.Specs/Widgets.feature index e681dda3c..95d282ce6 100644 --- a/src/Orchard.Specs/Widgets.feature +++ b/src/Orchard.Specs/Widgets.feature @@ -6,7 +6,8 @@ Scenario: I can edit a default layer Given I have installed Orchard When I go to "Admin/Widgets" - And I follow "Edit" + Then I should see "]*>Widgets[^>]*>" + When I follow "Edit" Then I should see "]*name="LayerPart.Name"[^>]*value="Default"[^>]*>" When I fill in | name | value | diff --git a/src/Orchard.Specs/Widgets.feature.cs b/src/Orchard.Specs/Widgets.feature.cs index 713111815..eb10c308f 100644 --- a/src/Orchard.Specs/Widgets.feature.cs +++ b/src/Orchard.Specs/Widgets.feature.cs @@ -3,7 +3,7 @@ // This code was generated by SpecFlow (http://www.specflow.org/). // SpecFlow Version:1.9.0.77 // SpecFlow Generator Version:1.9.0.0 -// Runtime Version:4.0.30319.33440 +// Runtime Version:4.0.30319.34014 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -77,8 +77,10 @@ this.ScenarioSetup(scenarioInfo); #line 8 testRunner.When("I go to \"Admin/Widgets\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); #line 9 - testRunner.And("I follow \"Edit\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); + testRunner.Then("I should see \"]*>Widgets[^>]*>\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); #line 10 + testRunner.When("I follow \"Edit\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 11 testRunner.Then("I should see \"]*name=\"LayerPart.Name\"[^>]*value=\"Default\"[^>]*>\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); #line hidden TechTalk.SpecFlow.Table table1 = new TechTalk.SpecFlow.Table(new string[] { @@ -87,17 +89,17 @@ this.ScenarioSetup(scenarioInfo); table1.AddRow(new string[] { "LayerPart.Description", "This is the default layer."}); -#line 11 +#line 12 testRunner.When("I fill in", ((string)(null)), table1, "When "); -#line 14 - testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line 15 - testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line 16 - testRunner.Then("I should see \"Your Layer has been saved\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); + testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line 17 - testRunner.When("I follow \"Edit\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); + testRunner.Then("I should see \"Your Layer has been saved\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); #line 18 + testRunner.When("I follow \"Edit\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 19 testRunner.Then("I should see \"]*>\\s*This is the default layer.\\s*\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); #line hidden this.ScenarioCleanup(); @@ -110,15 +112,15 @@ this.ScenarioSetup(scenarioInfo); { TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("I can add a new layer and that layer is active when I\'m redirected to the widget " + "management page", ((string[])(null))); -#line 20 -this.ScenarioSetup(scenarioInfo); #line 21 - testRunner.Given("I have installed Orchard", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +this.ScenarioSetup(scenarioInfo); #line 22 - testRunner.When("I go to \"Admin/Widgets\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); + testRunner.Given("I have installed Orchard", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); #line 23 - testRunner.And("I follow \"Add a new layer...\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); + testRunner.When("I go to \"Admin/Widgets\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); #line 24 + testRunner.And("I follow \"Add a new layer...\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 25 testRunner.Then("I should see \"]*>Add Layer\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); #line hidden TechTalk.SpecFlow.Table table2 = new TechTalk.SpecFlow.Table(new string[] { @@ -130,15 +132,15 @@ this.ScenarioSetup(scenarioInfo); table2.AddRow(new string[] { "LayerPart.LayerRule", "url \"~/awesome*\""}); -#line 25 +#line 26 testRunner.When("I fill in", ((string)(null)), table2, "When "); -#line 29 - testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line 30 - testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line 31 - testRunner.Then("I should see \"Your Layer has been created.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); + testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line 32 + testRunner.Then("I should see \"Your Layer has been created.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 33 testRunner.And("I should see \"]+selected=\"selected\"[^>]+value=\"\\d+\">For awesome stuff\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line hidden @@ -150,25 +152,25 @@ this.ScenarioSetup(scenarioInfo); public virtual void ICanDeleteALayer() { TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("I can delete a layer", ((string[])(null))); -#line 34 -this.ScenarioSetup(scenarioInfo); #line 35 - testRunner.Given("I have installed Orchard", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +this.ScenarioSetup(scenarioInfo); #line 36 - testRunner.When("I go to \"Admin/Widgets\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); + testRunner.Given("I have installed Orchard", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); #line 37 - testRunner.Then("I should see \"]*>Default\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); + testRunner.When("I go to \"Admin/Widgets\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); #line 38 - testRunner.When("I follow \"Edit\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); + testRunner.Then("I should see \"]*>Default\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); #line 39 - testRunner.Then("I should see \"]*name=\"LayerPart.Name\"[^>]*value=\"Default\"[^>]*>\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); + testRunner.When("I follow \"Edit\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); #line 40 - testRunner.When("I hit \"Delete\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); + testRunner.Then("I should see \"]*name=\"LayerPart.Name\"[^>]*value=\"Default\"[^>]*>\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); #line 41 - testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); + testRunner.When("I hit \"Delete\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); #line 42 - testRunner.Then("I should see \"Layer was successfully deleted\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); + testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line 43 + testRunner.Then("I should see \"Layer was successfully deleted\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 44 testRunner.And("I should not see \"]*>Default\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line hidden this.ScenarioCleanup(); @@ -179,11 +181,11 @@ this.ScenarioSetup(scenarioInfo); public virtual void ICanAddAWidgetToASpecificZoneInASpecificLayer() { TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("I can add a widget to a specific zone in a specific layer", ((string[])(null))); -#line 45 -this.ScenarioSetup(scenarioInfo); #line 46 - testRunner.Given("I have installed Orchard", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +this.ScenarioSetup(scenarioInfo); #line 47 + testRunner.Given("I have installed Orchard", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line 48 testRunner.When("I go to \"Admin/Widgets\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); #line hidden TechTalk.SpecFlow.Table table3 = new TechTalk.SpecFlow.Table(new string[] { @@ -192,19 +194,19 @@ this.ScenarioSetup(scenarioInfo); table3.AddRow(new string[] { "layerId", "Disabled"}); -#line 48 +#line 49 testRunner.And("I fill in", ((string)(null)), table3, "And "); -#line 51 - testRunner.And("I hit \"Show\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line 52 - testRunner.Then("I should see \"]*selected[^>]*>Disabled\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); + testRunner.And("I hit \"Show\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line 53 - testRunner.When("I follow \"Add\" where href has \"zone=Header\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); + testRunner.Then("I should see \"]*selected[^>]*>Disabled\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); #line 54 - testRunner.Then("I should see \"]*>Choose A Widget\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); + testRunner.When("I follow \"Add\" where href has \"zone=Header\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); #line 55 - testRunner.When("I follow \"

Html Widget

\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); + testRunner.Then("I should see \"]*>Choose A Widget\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); #line 56 + testRunner.When("I follow \"

Html Widget

\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 57 testRunner.Then("I should see \"]*>Add Widget\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); #line hidden TechTalk.SpecFlow.Table table4 = new TechTalk.SpecFlow.Table(new string[] { @@ -216,17 +218,17 @@ this.ScenarioSetup(scenarioInfo); table4.AddRow(new string[] { "Body.Text", "

hi

"}); -#line 57 +#line 58 testRunner.When("I fill in", ((string)(null)), table4, "When "); -#line 61 - testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line 62 - testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line 63 - testRunner.Then("I should see \"Your Html Widget has been added.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); + testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line 64 - testRunner.And("I should see \"]*selected[^>]*>Disabled\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); + testRunner.Then("I should see \"Your Html Widget has been added.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); #line 65 + testRunner.And("I should see \"]*selected[^>]*>Disabled\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 66 testRunner.And("I should see \"]*class=\"[^\"]*widgets-this-layer[^\"]*\"[^>]*>\\s*]*>\\s*" + "]*>\\s*]*>Flashy HTML Widget\\s*\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line hidden From 84feb2814ea4f15fb3c29d678ed50074b0cb6cf7 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Mon, 19 May 2014 16:00:04 -0700 Subject: [PATCH 4/9] Fixing Lists specflow tests --- src/Orchard.Specs/Lists.feature | 46 +++++++------- src/Orchard.Specs/Lists.feature.cs | 99 +++++++++++++----------------- 2 files changed, 63 insertions(+), 82 deletions(-) diff --git a/src/Orchard.Specs/Lists.feature b/src/Orchard.Specs/Lists.feature index 660b86f19..5074e822c 100644 --- a/src/Orchard.Specs/Lists.feature +++ b/src/Orchard.Specs/Lists.feature @@ -6,34 +6,30 @@ Scenario: I can create a new list Given I have installed Orchard And I have installed "Orchard.Lists" - When I go to "Admin/Contents/Create/List" + When I go to "Admin/ContentTypes" + And I go to "Admin/ContentTypes/Create" And I fill in - | name | value | - | Title.Title | MyList | - And I hit "Save" - And I go to "Admin/Contents/List/List" - Then I should see "MyList" + | name | value | + | DisplayName | Event | + | Name | Event | + And I hit "Create" + And I am redirected + And I fill in + | name | value | + | PartSelections[5].IsSelected | True | + And I hit "Save" + And I go to "Admin/ContentTypes/" + Then I should see "Event" -Scenario: I can add content items to a list - Given I have installed Orchard - And I have installed "Orchard.Lists" - And I have a containable content type "MyType" When I go to "Admin/Contents/Create/List" And I fill in - | name | value | - | Title.Title | MyList | + | name | value | + | Title.Title | MyList | + | Container.SelectedItemContentTypes | Event | And I hit "Save" - And I go to "Admin/Contents/List/List" + And I am redirected + Then I should see "Your List has been created" + When I go to "Admin/Lists" Then I should see "MyList" - When I follow "Contained Items" - Then I should see "The 'MyList' List has no content items." - When I follow "Create New Content" where href has "ReturnUrl" - Then I should see "MyType" - When I follow "MyType" where href has "ReturnUrl" - And I fill in - | name | value | - | Title.Title | MyContentItem | - And I hit "Save" - And I am redirected - Then I should see "Manage MyList" - And I should see "MyContentItem" + When I follow "Contained Items (0)" + Then I should see "'MyList' has no content items" diff --git a/src/Orchard.Specs/Lists.feature.cs b/src/Orchard.Specs/Lists.feature.cs index 6585debc4..a5bd6ef8b 100644 --- a/src/Orchard.Specs/Lists.feature.cs +++ b/src/Orchard.Specs/Lists.feature.cs @@ -3,7 +3,7 @@ // This code was generated by SpecFlow (http://www.specflow.org/). // SpecFlow Version:1.9.0.77 // SpecFlow Generator Version:1.9.0.0 -// Runtime Version:4.0.30319.33440 +// Runtime Version:4.0.30319.34014 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -77,83 +77,68 @@ this.ScenarioSetup(scenarioInfo); #line 8 testRunner.And("I have installed \"Orchard.Lists\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line 9 - testRunner.When("I go to \"Admin/Contents/Create/List\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); + testRunner.When("I go to \"Admin/ContentTypes\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 10 + testRunner.And("I go to \"Admin/ContentTypes/Create\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line hidden TechTalk.SpecFlow.Table table1 = new TechTalk.SpecFlow.Table(new string[] { "name", "value"}); table1.AddRow(new string[] { - "Title.Title", - "MyList"}); -#line 10 + "DisplayName", + "Event"}); + table1.AddRow(new string[] { + "Name", + "Event"}); +#line 11 testRunner.And("I fill in", ((string)(null)), table1, "And "); -#line 13 - testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); -#line 14 - testRunner.And("I go to \"Admin/Contents/List/List\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line 15 - testRunner.Then("I should see \"MyList\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); -#line hidden - this.ScenarioCleanup(); - } - - [NUnit.Framework.TestAttribute()] - [NUnit.Framework.DescriptionAttribute("I can add content items to a list")] - public virtual void ICanAddContentItemsToAList() - { - TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("I can add content items to a list", ((string[])(null))); -#line 17 -this.ScenarioSetup(scenarioInfo); -#line 18 - testRunner.Given("I have installed Orchard", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); -#line 19 - testRunner.And("I have installed \"Orchard.Lists\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); -#line 20 - testRunner.And("I have a containable content type \"MyType\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); -#line 21 - testRunner.When("I go to \"Admin/Contents/Create/List\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); + testRunner.And("I hit \"Create\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 16 + testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); #line hidden TechTalk.SpecFlow.Table table2 = new TechTalk.SpecFlow.Table(new string[] { "name", "value"}); table2.AddRow(new string[] { - "Title.Title", - "MyList"}); -#line 22 + "PartSelections[5].IsSelected", + "True"}); +#line 17 testRunner.And("I fill in", ((string)(null)), table2, "And "); -#line 25 - testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); -#line 26 - testRunner.And("I go to \"Admin/Contents/List/List\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); -#line 27 - testRunner.Then("I should see \"MyList\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); -#line 28 - testRunner.When("I follow \"Contained Items\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); -#line 29 - testRunner.Then("I should see \"The \'MyList\' List has no content items.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); -#line 30 - testRunner.When("I follow \"Create New Content\" where href has \"ReturnUrl\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); -#line 31 - testRunner.Then("I should see \"MyType\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); -#line 32 - testRunner.When("I follow \"MyType\" where href has \"ReturnUrl\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 20 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 21 + testRunner.And("I go to \"Admin/ContentTypes/\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 22 + testRunner.Then("I should see \"Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 24 + testRunner.When("I go to \"Admin/Contents/Create/List\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); #line hidden TechTalk.SpecFlow.Table table3 = new TechTalk.SpecFlow.Table(new string[] { "name", "value"}); table3.AddRow(new string[] { "Title.Title", - "MyContentItem"}); -#line 33 + "MyList"}); + table3.AddRow(new string[] { + "Container.SelectedItemContentTypes", + "Event"}); +#line 25 testRunner.And("I fill in", ((string)(null)), table3, "And "); -#line 36 +#line 29 testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); -#line 37 - testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); -#line 38 - testRunner.Then("I should see \"Manage MyList\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); -#line 39 - testRunner.And("I should see \"MyContentItem\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 30 + testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 31 + testRunner.Then("I should see \"Your List has been created\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 32 + testRunner.When("I go to \"Admin/Lists\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 33 + testRunner.Then("I should see \"MyList\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 34 + testRunner.When("I follow \"Contained Items (0)\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 35 + testRunner.Then("I should see \"\'MyList\' has no content items\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); #line hidden this.ScenarioCleanup(); } From 2e5b6014746a6f8f44e7f32044883884e51006d4 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Mon, 19 May 2014 16:14:15 -0700 Subject: [PATCH 5/9] Fixing multi-tenant specflow tests --- src/Orchard.Specs/Bindings/OrchardSiteFactory.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Orchard.Specs/Bindings/OrchardSiteFactory.cs b/src/Orchard.Specs/Bindings/OrchardSiteFactory.cs index 9a9606019..83db23086 100644 --- a/src/Orchard.Specs/Bindings/OrchardSiteFactory.cs +++ b/src/Orchard.Specs/Bindings/OrchardSiteFactory.cs @@ -104,6 +104,8 @@ namespace Orchard.Specs.Bindings { using (var environment = MvcApplication.CreateStandaloneEnvironment("Default")) { environment.Resolve().SaveSettings(shellSettings); } + + MvcApplication.RestartTenant(shellName); }); webApp.WhenIGoToPathOnHost("Setup", hostName); From bca9ca130483ff8102822837de173f067ab1d922 Mon Sep 17 00:00:00 2001 From: Lombiq Date: Tue, 20 May 2014 14:54:58 +0200 Subject: [PATCH 6/9] Orchard-style code formatting in Orchard.Templates --- .../Controllers/AdminController.cs | 2 +- .../Drivers/ShapePartDriver.cs | 28 +++++++++---------- .../Services/Razor/RazorCompiler.cs | 8 +++--- .../Services/Razor/RazorTemplateBase.cs | 6 ++-- .../Services/RazorTemplateProcessor.cs | 4 +-- .../Services/TemplateShapeDisplayEvent.cs | 6 ++-- .../Settings/ShapePartSettingsEvents.cs | 2 +- 7 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Templates/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Orchard.Templates/Controllers/AdminController.cs index ea98faeda..8ef5cee0a 100644 --- a/src/Orchard.Web/Modules/Orchard.Templates/Controllers/AdminController.cs +++ b/src/Orchard.Web/Modules/Orchard.Templates/Controllers/AdminController.cs @@ -159,7 +159,7 @@ namespace Orchard.Templates.Controllers { public ActionResult Create(string id) { var types = GetShapeTypes(); var typeName = String.IsNullOrWhiteSpace(id) ? types.Count() == 1 ? types.First().Name : null : id; - return String.IsNullOrEmpty(typeName) ? CreatableTypeList() : RedirectToAction("Create", "Admin", new {area = "Contents", id = typeName}); + return String.IsNullOrEmpty(typeName) ? CreatableTypeList() : RedirectToAction("Create", "Admin", new { area = "Contents", id = typeName }); } private ActionResult CreatableTypeList() { diff --git a/src/Orchard.Web/Modules/Orchard.Templates/Drivers/ShapePartDriver.cs b/src/Orchard.Web/Modules/Orchard.Templates/Drivers/ShapePartDriver.cs index 7826b4483..d0bf0083b 100644 --- a/src/Orchard.Web/Modules/Orchard.Templates/Drivers/ShapePartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Templates/Drivers/ShapePartDriver.cs @@ -36,19 +36,19 @@ namespace Orchard.Templates.Drivers { Template = part.Template }; - if (updater != null + if (updater != null && updater.TryUpdateModel(viewModel, Prefix, null, new[] { "AvailableLanguages" }) && ValidateShapeName(part, updater)) { - part.Template = viewModel.Template; + part.Template = viewModel.Template; - try { - var processor = _processors.FirstOrDefault(x => String.Equals(x.Type, part.ProcessorName, StringComparison.OrdinalIgnoreCase)) ?? _processors.First(); - processor.Verify(part.Template); - } - catch (Exception ex) { - updater.AddModelError("", T("Template processing error: {0}", ex.Message)); - _transactions.Cancel(); - } + try { + var processor = _processors.FirstOrDefault(x => String.Equals(x.Type, part.ProcessorName, StringComparison.OrdinalIgnoreCase)) ?? _processors.First(); + processor.Verify(part.Template); + } + catch (Exception ex) { + updater.AddModelError("", T("Template processing error: {0}", ex.Message)); + _transactions.Cancel(); + } } return ContentShape("Parts_Shape_Edit", () => shapeHelper.EditorTemplate(TemplateName: "Parts.Shape", Model: viewModel, Prefix: Prefix)); } @@ -60,7 +60,7 @@ namespace Orchard.Templates.Drivers { protected override void Importing(ShapePart part, ImportContentContext context) { var shapeElement = context.Data.Element(part.PartDefinition.Name); - if(shapeElement != null) + if (shapeElement != null) part.Template = shapeElement.Value; } @@ -70,9 +70,9 @@ namespace Orchard.Templates.Drivers { return false; var name = titleViewModel.Title; - if (!string.IsNullOrWhiteSpace(name) && - name[0].IsLetter() && - name.All(c => c.IsLetter() || Char.IsDigit(c) || c == '.' || c == '-' )) { + if (!string.IsNullOrWhiteSpace(name) && + name[0].IsLetter() && + name.All(c => c.IsLetter() || Char.IsDigit(c) || c == '.' || c == '-')) { return true; } diff --git a/src/Orchard.Web/Modules/Orchard.Templates/Services/Razor/RazorCompiler.cs b/src/Orchard.Web/Modules/Orchard.Templates/Services/Razor/RazorCompiler.cs index 9b82a3032..3e0b80400 100644 --- a/src/Orchard.Web/Modules/Orchard.Templates/Services/Razor/RazorCompiler.cs +++ b/src/Orchard.Web/Modules/Orchard.Templates/Services/Razor/RazorCompiler.cs @@ -46,7 +46,7 @@ namespace Orchard.Templates.Compilation.Razor { }; public RazorCompiler( - ICacheManager cache, + ICacheManager cache, ISignals signals) { _cache = cache; _signals = signals; @@ -56,15 +56,15 @@ namespace Orchard.Templates.Compilation.Razor { private ILogger Logger { get; set; } public IRazorTemplateBase CompileRazor(string code, string name, IDictionary parameters) { - return (RazorTemplateBase) Compile(code, name, typeof (TModel), parameters); + return (RazorTemplateBase)Compile(code, name, typeof(TModel), parameters); } public IRazorTemplateBase CompileRazor(string code, string name, IDictionary parameters) { - return (IRazorTemplateBase) Compile(code, name, null, parameters); + return (IRazorTemplateBase)Compile(code, name, null, parameters); } private object Compile(string code, string name, Type modelType, IDictionary parameters) { - + var cacheKey = (name ?? DynamicallyGeneratedClassName) + GetHash(code); var generatedClassName = name != null ? name.Strip(c => !c.IsLetter() && !Char.IsDigit(c)) : DynamicallyGeneratedClassName; diff --git a/src/Orchard.Web/Modules/Orchard.Templates/Services/Razor/RazorTemplateBase.cs b/src/Orchard.Web/Modules/Orchard.Templates/Services/Razor/RazorTemplateBase.cs index 2a5e157cd..d070700ce 100644 --- a/src/Orchard.Web/Modules/Orchard.Templates/Services/Razor/RazorTemplateBase.cs +++ b/src/Orchard.Web/Modules/Orchard.Templates/Services/Razor/RazorTemplateBase.cs @@ -3,8 +3,7 @@ using System.Web.Mvc; using System.Web.WebPages; namespace Orchard.Templates.Compilation.Razor { - public interface IRazorTemplateBase - { + public interface IRazorTemplateBase { dynamic Model { get; } WebPageContext WebPageContext { get; set; } ViewContext ViewContext { get; set; } @@ -15,8 +14,7 @@ namespace Orchard.Templates.Compilation.Razor { } - public interface IRazorTemplateBase : IRazorTemplateBase - { + public interface IRazorTemplateBase : IRazorTemplateBase { new TModel Model { get; } new ViewDataDictionary ViewData { get; set; } } diff --git a/src/Orchard.Web/Modules/Orchard.Templates/Services/RazorTemplateProcessor.cs b/src/Orchard.Web/Modules/Orchard.Templates/Services/RazorTemplateProcessor.cs index 22f5824aa..2d51eb51c 100644 --- a/src/Orchard.Web/Modules/Orchard.Templates/Services/RazorTemplateProcessor.cs +++ b/src/Orchard.Web/Modules/Orchard.Templates/Services/RazorTemplateProcessor.cs @@ -19,7 +19,7 @@ namespace Orchard.Templates.Services { } public RazorTemplateProcessor( - IRazorCompiler compiler, + IRazorCompiler compiler, HttpContextBase httpContextBase) { _compiler = compiler; _httpContextBase = httpContextBase; @@ -58,7 +58,7 @@ namespace Orchard.Templates.Services { obj.WebPageContext = new WebPageContext(displayContext.ViewContext.HttpContext, obj as WebPageRenderingBase, model); obj.ViewContext = shapeViewContext; - obj.ViewData = new ViewDataDictionary(displayContext.ViewDataContainer.ViewData) {Model = model}; + obj.ViewData = new ViewDataDictionary(displayContext.ViewDataContainer.ViewData) { Model = model }; obj.InitHelpers(); } else { diff --git a/src/Orchard.Web/Modules/Orchard.Templates/Services/TemplateShapeDisplayEvent.cs b/src/Orchard.Web/Modules/Orchard.Templates/Services/TemplateShapeDisplayEvent.cs index d15838fd9..4118296a1 100644 --- a/src/Orchard.Web/Modules/Orchard.Templates/Services/TemplateShapeDisplayEvent.cs +++ b/src/Orchard.Web/Modules/Orchard.Templates/Services/TemplateShapeDisplayEvent.cs @@ -15,8 +15,8 @@ namespace Orchard.Templates.Services { private IContentManager _contentManager; private ITemplateService _templateService; - public TemplateShapeDisplayEvent ( - ICacheManager cacheManager, + public TemplateShapeDisplayEvent( + ICacheManager cacheManager, ISignals signals, IContentManager contentManager, ITemplateService templateService @@ -41,7 +41,7 @@ namespace Orchard.Templates.Services { public IDictionary> BuildShapeProcessors() { return _cacheManager.Get("Template.ShapeProcessors", ctx => { - ctx.Monitor(_signals.When(DefaultTemplateService.TemplatesSignal)); + ctx.Monitor(_signals.When(DefaultTemplateService.TemplatesSignal)); var allTemplates = _contentManager.Query().List(); diff --git a/src/Orchard.Web/Modules/Orchard.Templates/Settings/ShapePartSettingsEvents.cs b/src/Orchard.Web/Modules/Orchard.Templates/Settings/ShapePartSettingsEvents.cs index 802a85c6b..7533bd674 100644 --- a/src/Orchard.Web/Modules/Orchard.Templates/Settings/ShapePartSettingsEvents.cs +++ b/src/Orchard.Web/Modules/Orchard.Templates/Settings/ShapePartSettingsEvents.cs @@ -35,7 +35,7 @@ namespace Orchard.Templates.Settings { AvailableProcessors = _processors.ToArray() }; - updateModel.TryUpdateModel(model, "ShapePartSettingsViewModel", new[] {"Processor"}, null); + updateModel.TryUpdateModel(model, "ShapePartSettingsViewModel", new[] { "Processor" }, null); builder.WithSetting("ShapePartSettings.Processor", model.Processor); yield return DefinitionTemplate(model); } From 45392f60de3fcb59e8587fce08c9b5175dd1df48 Mon Sep 17 00:00:00 2001 From: Lombiq Date: Tue, 20 May 2014 16:03:55 +0200 Subject: [PATCH 7/9] #20658: Factored out Razor-related services in Templates to separate feature. Work Item: 20658 --- .../Modules/Orchard.Templates/Migrations.cs | 3 +-- .../Modules/Orchard.Templates/Module.txt | 11 +++++--- .../Orchard.Templates.csproj | 2 ++ .../Orchard.Templates/RazorMigrations.cs | 19 +++++++++++++ .../Services/NoTemplateProcessorBanner.cs | 27 +++++++++++++++++++ .../Services/Razor/IRazorCompiler.cs | 2 +- .../Services/Razor/RazorCompiler.cs | 2 ++ .../Services/RazorTemplateProcessor.cs | 3 +++ 8 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 src/Orchard.Web/Modules/Orchard.Templates/RazorMigrations.cs create mode 100644 src/Orchard.Web/Modules/Orchard.Templates/Services/NoTemplateProcessorBanner.cs diff --git a/src/Orchard.Web/Modules/Orchard.Templates/Migrations.cs b/src/Orchard.Web/Modules/Orchard.Templates/Migrations.cs index 4f75a0da3..4b68c649d 100644 --- a/src/Orchard.Web/Modules/Orchard.Templates/Migrations.cs +++ b/src/Orchard.Web/Modules/Orchard.Templates/Migrations.cs @@ -14,8 +14,7 @@ namespace Orchard.Templates { .WithPart("CommonPart") .WithPart("IdentityPart") .WithPart("TitlePart") - .WithPart("ShapePart", p => p - .WithSetting("ShapePartSettings.Processor", "Razor")) + .WithPart("ShapePart") .Draftable()); return 1; } diff --git a/src/Orchard.Web/Modules/Orchard.Templates/Module.txt b/src/Orchard.Web/Modules/Orchard.Templates/Module.txt index f4515b3a5..60176b8fd 100644 --- a/src/Orchard.Web/Modules/Orchard.Templates/Module.txt +++ b/src/Orchard.Web/Modules/Orchard.Templates/Module.txt @@ -4,10 +4,15 @@ Author: The Orchard Team Website: http://orchardproject.net Version: 1.8.1 OrchardVersion: 1.8 -Description: Provides a Template type that can be used to store Razor code and used as a shape. +Description: Provides a Template type that can be used to store template code and used as a shape. Features: Orchard.Templates: Name: Templates - Description: Provides a Template type that represents a Razor template, stored as a content item. + Description: Provides a Template type that represents a shape template, stored as a content item. Category: Content - Dependencies: Contents, Orchard.Tokens \ No newline at end of file + Dependencies: Contents, Orchard.Tokens + Orchard.Templates.Razor: + Name: Razor Templates + Description: Extends Templates with Razor templates. + Category: Content + Dependencies: Orchard.Templates \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Templates/Orchard.Templates.csproj b/src/Orchard.Web/Modules/Orchard.Templates/Orchard.Templates.csproj index 8b3b3c022..c5c39e305 100644 --- a/src/Orchard.Web/Modules/Orchard.Templates/Orchard.Templates.csproj +++ b/src/Orchard.Web/Modules/Orchard.Templates/Orchard.Templates.csproj @@ -167,8 +167,10 @@ + + diff --git a/src/Orchard.Web/Modules/Orchard.Templates/RazorMigrations.cs b/src/Orchard.Web/Modules/Orchard.Templates/RazorMigrations.cs new file mode 100644 index 000000000..212701966 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Templates/RazorMigrations.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using Orchard.Data.Migration; +using Orchard.ContentManagement.MetaData; +using Orchard.Environment.Extensions; + +namespace Orchard.Templates { + [OrchardFeature("Orchard.Templates.Razor")] + public class RazorMigrations : DataMigrationImpl { + public int Create() { + ContentDefinitionManager.AlterTypeDefinition("Template", type => type + .WithPart("ShapePart", p => p + .WithSetting("ShapePartSettings.Processor", "Razor"))); + return 1; + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Templates/Services/NoTemplateProcessorBanner.cs b/src/Orchard.Web/Modules/Orchard.Templates/Services/NoTemplateProcessorBanner.cs new file mode 100644 index 000000000..4ca686166 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Templates/Services/NoTemplateProcessorBanner.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using Orchard.Localization; +using Orchard.UI.Admin.Notification; +using Orchard.UI.Notify; + +namespace Orchard.Templates.Services { + public class NoTemplateProcessorBanner : INotificationProvider { + private readonly IEnumerable _processors; + + public NoTemplateProcessorBanner(IEnumerable processors) { + _processors = processors; + + T = NullLocalizer.Instance; + } + + public Localizer T { get; set; } + + public IEnumerable GetNotifications() { + if (!_processors.Any()) { + yield return new NotifyEntry { Message = T("To be able to use Templates enable a template processor like Razor Templates."), Type = NotifyType.Warning }; + } + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Templates/Services/Razor/IRazorCompiler.cs b/src/Orchard.Web/Modules/Orchard.Templates/Services/Razor/IRazorCompiler.cs index 9480061ec..869864581 100644 --- a/src/Orchard.Web/Modules/Orchard.Templates/Services/Razor/IRazorCompiler.cs +++ b/src/Orchard.Web/Modules/Orchard.Templates/Services/Razor/IRazorCompiler.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; namespace Orchard.Templates.Compilation.Razor { - public interface IRazorCompiler : IDependency { + public interface IRazorCompiler : IDependency { IRazorTemplateBase CompileRazor(string code, string name, IDictionary parameters); IRazorTemplateBase CompileRazor(string code, string name, IDictionary parameters); } diff --git a/src/Orchard.Web/Modules/Orchard.Templates/Services/Razor/RazorCompiler.cs b/src/Orchard.Web/Modules/Orchard.Templates/Services/Razor/RazorCompiler.cs index 3e0b80400..615ddcb7c 100644 --- a/src/Orchard.Web/Modules/Orchard.Templates/Services/Razor/RazorCompiler.cs +++ b/src/Orchard.Web/Modules/Orchard.Templates/Services/Razor/RazorCompiler.cs @@ -10,10 +10,12 @@ using System.Text; using System.Web.Razor; using Microsoft.CSharp; using Orchard.Caching; +using Orchard.Environment.Extensions; using Orchard.Logging; using Orchard.Utility.Extensions; namespace Orchard.Templates.Compilation.Razor { + [OrchardFeature("Orchard.Templates.Razor")] public class RazorCompiler : IRazorCompiler { private readonly ICacheManager _cache; private readonly ISignals _signals; diff --git a/src/Orchard.Web/Modules/Orchard.Templates/Services/RazorTemplateProcessor.cs b/src/Orchard.Web/Modules/Orchard.Templates/Services/RazorTemplateProcessor.cs index 2d51eb51c..88735f926 100644 --- a/src/Orchard.Web/Modules/Orchard.Templates/Services/RazorTemplateProcessor.cs +++ b/src/Orchard.Web/Modules/Orchard.Templates/Services/RazorTemplateProcessor.cs @@ -7,9 +7,12 @@ using System.Web.Mvc; using System.Web.UI; using System.Web.WebPages; using Orchard.DisplayManagement.Implementation; +using Orchard.Environment.Extensions; using Orchard.Logging; using Orchard.Templates.Compilation.Razor; + namespace Orchard.Templates.Services { + [OrchardFeature("Orchard.Templates.Razor")] public class RazorTemplateProcessor : TemplateProcessorImpl { private readonly IRazorCompiler _compiler; private readonly HttpContextBase _httpContextBase; From 6e49ad2ce283e1358ca2aee1ca716f80f093bcba Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Tue, 20 May 2014 20:04:19 +0200 Subject: [PATCH 8/9] Changed the Template title syntax requirements. This change makes it possible to use "complex" shape names (e.g. "Email__Wrapper"). Before this change, the shape file name syntax was required (e.g. "Email-Wrapper"). However, such shapes would not be found when using the {Shape.Execute} token when using the other syntax (e.g. "Email__Wrapper"), since TemplateShapeDisplayEvent simply register the shapes by specified title without first translating the file based syntax to code based syntax. --- .../Modules/Orchard.Templates/Drivers/ShapePartDriver.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Templates/Drivers/ShapePartDriver.cs b/src/Orchard.Web/Modules/Orchard.Templates/Drivers/ShapePartDriver.cs index d0bf0083b..0cd70d87f 100644 --- a/src/Orchard.Web/Modules/Orchard.Templates/Drivers/ShapePartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Templates/Drivers/ShapePartDriver.cs @@ -70,13 +70,13 @@ namespace Orchard.Templates.Drivers { return false; var name = titleViewModel.Title; - if (!string.IsNullOrWhiteSpace(name) && + if (!String.IsNullOrWhiteSpace(name) && name[0].IsLetter() && - name.All(c => c.IsLetter() || Char.IsDigit(c) || c == '.' || c == '-')) { + name.All(c => c.IsLetter() || Char.IsDigit(c) || c == '_')) { return true; } - updater.AddModelError("Title", T("{0} names can only contain alphanumerical, dot (.) or dash (-) characters and have to start with a letter.", part.ContentItem.TypeDefinition.DisplayName)); + updater.AddModelError("Title", T("{0} names can only contain alphanumerical or underscore (_) characters and have to start with a letter.", part.ContentItem.TypeDefinition.DisplayName)); return false; } From a1039f56091f9fbf84295c8794fe188ffbf45e5e Mon Sep 17 00:00:00 2001 From: Lombiq Date: Wed, 21 May 2014 18:48:20 +0200 Subject: [PATCH 9/9] Orchard.Framework/Caching: Fixing typo in a comment in Cache.cs --- src/Orchard/Caching/Cache.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Orchard/Caching/Cache.cs b/src/Orchard/Caching/Cache.cs index 431ee7293..ab2178c6e 100644 --- a/src/Orchard/Caching/Cache.cs +++ b/src/Orchard/Caching/Cache.cs @@ -17,7 +17,7 @@ namespace Orchard.Caching { var entry = _entries.AddOrUpdate(key, // "Add" lambda k => AddEntry(k, acquire), - // "Update" lamdba + // "Update" lambda (k, currentEntry) => UpdateEntry(currentEntry, k, acquire)); return entry.Result;