Fixes: #U4-1819
This commit is contained in:
@@ -10,6 +10,77 @@ namespace Umbraco.Tests
|
||||
[TestFixture]
|
||||
public class EnumerableExtensionsTests
|
||||
{
|
||||
|
||||
[Test]
|
||||
public void Flatten_List()
|
||||
{
|
||||
var hierarchy = new TestItem()
|
||||
{
|
||||
Children = new List<TestItem>()
|
||||
{
|
||||
new TestItem()
|
||||
{
|
||||
Children = new List<TestItem>()
|
||||
{
|
||||
new TestItem()
|
||||
{
|
||||
Children = new List<TestItem>()
|
||||
{
|
||||
new TestItem()
|
||||
{
|
||||
Children = new List<TestItem>()
|
||||
{
|
||||
new TestItem(),
|
||||
new TestItem()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
new TestItem()
|
||||
{
|
||||
Children = new List<TestItem>()
|
||||
{
|
||||
new TestItem()
|
||||
{
|
||||
Children = new List<TestItem>()
|
||||
{
|
||||
new TestItem()
|
||||
{
|
||||
Children = new List<TestItem>()
|
||||
}
|
||||
}
|
||||
},
|
||||
new TestItem()
|
||||
{
|
||||
Children = new List<TestItem>()
|
||||
{
|
||||
new TestItem()
|
||||
{
|
||||
Children = new List<TestItem>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
var flattened = hierarchy.Children.FlattenList(x => x.Children);
|
||||
|
||||
Assert.AreEqual(10, flattened.Count());
|
||||
}
|
||||
|
||||
private class TestItem
|
||||
{
|
||||
public TestItem()
|
||||
{
|
||||
Children = Enumerable.Empty<TestItem>();
|
||||
}
|
||||
public IEnumerable<TestItem> Children { get; set; }
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InGroupsOf_ReturnsAllElements()
|
||||
{
|
||||
|
||||
20
src/Umbraco.Web/Mvc/NotChildAction.cs
Normal file
20
src/Umbraco.Web/Mvc/NotChildAction.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Umbraco.Web.Mvc
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to ensure that actions with duplicate names that are not child actions don't get executed when
|
||||
/// we are Posting and not redirecting.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See issue: http://issues.umbraco.org/issue/U4-1819
|
||||
/// </remarks>
|
||||
public class NotChildAction : ActionMethodSelectorAttribute
|
||||
{
|
||||
public override bool IsValidForRequest(ControllerContext controllerContext, System.Reflection.MethodInfo methodInfo)
|
||||
{
|
||||
var isChildAction = controllerContext.IsChildAction;
|
||||
return !isChildAction;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -273,6 +273,7 @@
|
||||
<Compile Include="DefaultPublishedMediaStore.cs" />
|
||||
<Compile Include="Dictionary\UmbracoCultureDictionary.cs" />
|
||||
<Compile Include="Dictionary\UmbracoCultureDictionaryFactory.cs" />
|
||||
<Compile Include="Mvc\NotChildAction.cs" />
|
||||
<Compile Include="Mvc\UmbracoViewPage.cs" />
|
||||
<Compile Include="PublishedContentExtensions.cs" />
|
||||
<Compile Include="ExamineExtensions.cs" />
|
||||
|
||||
Reference in New Issue
Block a user