mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Fixing moderated comments
--HG-- branch : 1.x
This commit is contained in:
@@ -41,4 +41,37 @@ Scenario: HTML markup in any given comment is encoded
|
||||
# because the ToUrlString extension method breaks in this specific (test) environment, the returnUrl is broken...
|
||||
And I go to "my-blog/my-post"
|
||||
Then I should see "This is<br id="bad-anon-br" />a <a href"
|
||||
And I should not see "<br id="bad-anon-br" />"
|
||||
And I should not see "<br id="bad-anon-br" />"
|
||||
|
||||
Scenario: Moderated comments are not displayed
|
||||
Given I have installed Orchard
|
||||
When I go to "admin/blogs/create"
|
||||
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"
|
||||
And I go to "admin/settings/comments"
|
||||
And I fill in
|
||||
| name | value |
|
||||
| CommentSettings.ModerateComments | true |
|
||||
And I hit "Save"
|
||||
And I am redirected
|
||||
Then I should see "Settings updated"
|
||||
When I go to "my-blog/my-post"
|
||||
And I fill in
|
||||
| name | value |
|
||||
| Comments.CommentText | This is a moderated comment. |
|
||||
And I hit "Submit Comment"
|
||||
And I am redirected
|
||||
# because the ToUrlString extension method breaks in this specific (test) environment, the returnUrl is broken...
|
||||
And I go to "my-blog/my-post"
|
||||
Then I should see "Hi there"
|
||||
And I should not see "This is a moderated comment"
|
||||
|
84
src/Orchard.Specs/Comments.feature.cs
generated
84
src/Orchard.Specs/Comments.feature.cs
generated
@@ -156,6 +156,90 @@ 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 \"<br id=\"bad-anon-br\" />\"", ((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 ");
|
||||
#line hidden
|
||||
TechTalk.SpecFlow.Table table5 = new TechTalk.SpecFlow.Table(new string[] {
|
||||
"name",
|
||||
"value"});
|
||||
table5.AddRow(new string[] {
|
||||
"Title.Title",
|
||||
"My Blog"});
|
||||
#line 49
|
||||
testRunner.And("I fill in", ((string)(null)), table5, "And ");
|
||||
#line 52
|
||||
testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
|
||||
#line 53
|
||||
testRunner.And("I go to \"admin/blogs\"", ((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 ");
|
||||
#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 ");
|
||||
#line 60
|
||||
testRunner.And("I hit \"Publish Now\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
|
||||
#line 61
|
||||
testRunner.And("I go to \"admin/settings/comments\"", ((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 \"my-blog/my-post\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
|
||||
#line hidden
|
||||
TechTalk.SpecFlow.Table table8 = new TechTalk.SpecFlow.Table(new string[] {
|
||||
"name",
|
||||
"value"});
|
||||
table8.AddRow(new string[] {
|
||||
"Comments.CommentText",
|
||||
"This is a moderated comment."});
|
||||
#line 69
|
||||
testRunner.And("I fill in", ((string)(null)), table8, "And ");
|
||||
#line 72
|
||||
testRunner.And("I hit \"Submit Comment\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
|
||||
#line 73
|
||||
testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
|
||||
#line 75
|
||||
testRunner.And("I go to \"my-blog/my-post\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
|
||||
#line 76
|
||||
testRunner.Then("I should see \"Hi there\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
|
||||
#line 77
|
||||
testRunner.And("I should not see \"This is a moderated comment\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
|
||||
#line hidden
|
||||
this.ScenarioCleanup();
|
||||
}
|
||||
|
@@ -41,7 +41,7 @@ namespace Orchard.Comments.Drivers {
|
||||
// create a hierarchy of shapes
|
||||
var firstLevelShapes = new List<dynamic>();
|
||||
var allShapes = new Dictionary<int, dynamic>();
|
||||
var comments = commentsForCommentedContent.OrderBy(x => x.Position).List().ToList();
|
||||
var comments = commentsForCommentedContent.Where(x => x.Status == CommentStatus.Approved).OrderBy(x => x.Position).List().ToList();
|
||||
|
||||
foreach (var item in comments) {
|
||||
var formatted = _htmlFilters.Where(x => x.GetType().Name.Equals(settings.HtmlFilter, StringComparison.OrdinalIgnoreCase)).Aggregate(item.CommentText, (text, filter) => filter.ProcessContent(text));
|
||||
|
Reference in New Issue
Block a user