Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

.shade file lookup support for MVC

  • Loading branch information...
commit ef48a7cd87339696a192c15bd4e683eef93cae41 1 parent be1119a
@RobertTheGrey RobertTheGrey authored
View
163 src/Spark.Web.Mvc.Tests/DescriptorBuildingTester.cs
@@ -75,6 +75,19 @@ public void NormalViewAndNoDefaultLayout()
}
[Test]
+ public void NormalViewAndNoDefaultLayoutWithShade()
+ {
+ _routeData.Values.Add("controller", "Home");
+ _viewFolder.Add(@"Home\Index.shade", "");
+
+ var searchedLocations = new List<string>();
+ var result = _factory.CreateDescriptor(_controllerContext, "Index", null, true, searchedLocations);
+ AssertDescriptorTemplates(
+ result, searchedLocations,
+ @"Home\Index.shade");
+ }
+
+ [Test]
public void NormalViewAndDefaultLayoutPresent()
{
_routeData.Values.Add("controller", "Home");
@@ -89,6 +102,20 @@ public void NormalViewAndDefaultLayoutPresent()
@"Layouts\Application.spark");
}
+ [Test]
+ public void NormalViewAndDefaultLayoutPresentWithShade()
+ {
+ _routeData.Values.Add("controller", "Home");
+ _viewFolder.Add(@"Home\Index.shade", "");
+ _viewFolder.Add(@"Layouts\Application.shade", "");
+
+ var searchedLocations = new List<string>();
+ var result = _factory.CreateDescriptor(_controllerContext, "Index", null, true, searchedLocations);
+ AssertDescriptorTemplates(
+ result, searchedLocations,
+ @"Home\Index.shade",
+ @"Layouts\Application.shade");
+ }
[Test]
public void NormalViewAndControllerLayoutOverrides()
@@ -107,6 +134,22 @@ public void NormalViewAndControllerLayoutOverrides()
}
[Test]
+ public void NormalViewAndControllerLayoutOverridesWithShade()
+ {
+ _routeData.Values.Add("controller", "Home");
+ _viewFolder.Add(@"Home\Index.shade", "");
+ _viewFolder.Add(@"Layouts\Application.shade", "");
+ _viewFolder.Add(@"Layouts\Home.shade", "");
+
+ var searchedLocations = new List<string>();
+ var result = _factory.CreateDescriptor(_controllerContext, "Index", null, true, searchedLocations);
+ AssertDescriptorTemplates(
+ result, searchedLocations,
+ @"Home\Index.shade",
+ @"Layouts\Home.shade");
+ }
+
+ [Test]
public void NormalViewAndNamedMaster()
{
_routeData.Values.Add("controller", "Home");
@@ -124,6 +167,23 @@ public void NormalViewAndNamedMaster()
}
[Test]
+ public void NormalViewAndNamedMasterWithShade()
+ {
+ _routeData.Values.Add("controller", "Home");
+ _viewFolder.Add(@"Home\Index.shade", "");
+ _viewFolder.Add(@"Layouts\Application.shade", "");
+ _viewFolder.Add(@"Layouts\Home.shade", "");
+ _viewFolder.Add(@"Layouts\Site.shade", "");
+
+ var searchedLocations = new List<string>();
+ var result = _factory.CreateDescriptor(_controllerContext, "Index", "Site", true, searchedLocations);
+ AssertDescriptorTemplates(
+ result, searchedLocations,
+ @"Home\Index.shade",
+ @"Layouts\Site.shade");
+ }
+
+ [Test]
public void PartialViewIgnoresDefaultLayouts()
{
_routeData.Values.Add("controller", "Home");
@@ -141,6 +201,23 @@ public void PartialViewIgnoresDefaultLayouts()
}
[Test]
+ public void PartialViewIgnoresDefaultLayoutsWithShade()
+ {
+ _routeData.Values.Add("controller", "Home");
+ _viewFolder.Add(@"Home\Index.shade", "");
+ _viewFolder.Add(@"Layouts\Application.shade", "");
+ _viewFolder.Add(@"Layouts\Home.shade", "");
+ _viewFolder.Add(@"Shared\Application.shade", "");
+ _viewFolder.Add(@"Shared\Home.shade", "");
+
+ var searchedLocations = new List<string>();
+ var result = _factory.CreateDescriptor(_controllerContext, "Index", null, false, searchedLocations);
+ AssertDescriptorTemplates(
+ result, searchedLocations,
+ @"Home\Index.shade");
+ }
+
+ [Test]
public void RouteAreaPresentDefaultsToNormalLocation()
{
_routeData.DataTokens.Add("area", "Admin");
@@ -157,6 +234,22 @@ public void RouteAreaPresentDefaultsToNormalLocation()
}
[Test]
+ public void RouteAreaPresentDefaultsToNormalLocationWithShade()
+ {
+ _routeData.DataTokens.Add("area", "Admin");
+ _routeData.Values.Add("controller", "Home");
+ _viewFolder.Add(@"Home\Index.shade", "");
+ _viewFolder.Add(@"Layouts\Application.shade", "");
+
+ var searchedLocations = new List<string>();
+ var result = _factory.CreateDescriptor(_controllerContext, "Index", null, true, searchedLocations);
+ AssertDescriptorTemplates(
+ result, searchedLocations,
+ @"Home\Index.shade",
+ @"Layouts\Application.shade");
+ }
+
+ [Test]
public void AreaFolderMayContainControllerFolder()
{
_routeData.DataTokens.Add("area", "Admin");
@@ -174,6 +267,23 @@ public void AreaFolderMayContainControllerFolder()
}
[Test]
+ public void AreaFolderMayContainControllerFolderWithShade()
+ {
+ _routeData.DataTokens.Add("area", "Admin");
+ _routeData.Values.Add("controller", "Home");
+ _viewFolder.Add(@"Home\Index.shade", "");
+ _viewFolder.Add(@"Layouts\Application.shade", "");
+ _viewFolder.Add(@"Admin\Home\Index.shade", "");
+
+ var searchedLocations = new List<string>();
+ var result = _factory.CreateDescriptor(_controllerContext, "Index", null, true, searchedLocations);
+ AssertDescriptorTemplates(
+ result, searchedLocations,
+ @"Admin\Home\Index.shade",
+ @"Layouts\Application.shade");
+ }
+
+ [Test]
public void AreaRouteValueAlsoRecognizedForBackCompatWithEarlierAssumptions() {
_routeData.Values.Add("area", "Admin");
_routeData.Values.Add("controller", "Home");
@@ -190,6 +300,22 @@ public void AreaFolderMayContainControllerFolder()
}
[Test]
+ public void AreaRouteValueAlsoRecognizedForBackCompatWithEarlierAssumptionsWithShade() {
+ _routeData.Values.Add("area", "Admin");
+ _routeData.Values.Add("controller", "Home");
+ _viewFolder.Add(@"Home\Index.shade", "");
+ _viewFolder.Add(@"Layouts\Application.shade", "");
+ _viewFolder.Add(@"Admin\Home\Index.shade", "");
+
+ var searchedLocations = new List<string>();
+ var result = _factory.CreateDescriptor(_controllerContext, "Index", null, true, searchedLocations);
+ AssertDescriptorTemplates(
+ result, searchedLocations,
+ @"Admin\Home\Index.shade",
+ @"Layouts\Application.shade");
+ }
+
+ [Test]
public void AreaFolderMayContainLayoutsFolder()
{
_routeData.DataTokens.Add("area", "Admin");
@@ -208,6 +334,24 @@ public void AreaFolderMayContainLayoutsFolder()
}
[Test]
+ public void AreaFolderMayContainLayoutsFolderWithShade()
+ {
+ _routeData.DataTokens.Add("area", "Admin");
+ _routeData.Values.Add("controller", "Home");
+ _viewFolder.Add(@"Home\Index.shade", "");
+ _viewFolder.Add(@"Layouts\Application.shade", "");
+ _viewFolder.Add(@"Admin\Home\Index.shade", "");
+ _viewFolder.Add(@"Admin\Layouts\Application.shade", "");
+
+ var searchedLocations = new List<string>();
+ var result = _factory.CreateDescriptor(_controllerContext, "Index", null, true, searchedLocations);
+ AssertDescriptorTemplates(
+ result, searchedLocations,
+ @"Admin\Home\Index.shade",
+ @"Admin\Layouts\Application.shade");
+ }
+
+ [Test]
public void AreaContainsNamedLayout()
{
_routeData.DataTokens.Add("area", "Admin");
@@ -227,6 +371,25 @@ public void AreaContainsNamedLayout()
}
[Test]
+ public void AreaContainsNamedLayoutWithShade()
+ {
+ _routeData.DataTokens.Add("area", "Admin");
+ _routeData.Values.Add("controller", "Home");
+ _viewFolder.Add(@"Home\Index.shade", "");
+ _viewFolder.Add(@"Layouts\Application.shade", "");
+ _viewFolder.Add(@"Admin\Home\Index.shade", "");
+ _viewFolder.Add(@"Admin\Layouts\Application.shade", "");
+ _viewFolder.Add(@"Admin\Layouts\Site.shade", "");
+
+ var searchedLocations = new List<string>();
+ var result = _factory.CreateDescriptor(_controllerContext, "Index", "Site", true, searchedLocations);
+ AssertDescriptorTemplates(
+ result, searchedLocations,
+ @"Admin\Home\Index.shade",
+ @"Admin\Layouts\Site.shade");
+ }
+
+ [Test]
public void PartialViewFromAreaIgnoresLayout()
{
_routeData.DataTokens.Add("area", "Admin");
View
28 src/Spark.Web.Mvc/DefaultDescriptorBuilder.cs
@@ -197,12 +197,18 @@ protected virtual IEnumerable<string> PotentialViewLocations(string controllerNa
string.Format("~{0}Areas{0}{1}{0}Views{0}Shared{0}{2}.spark", Path.DirectorySeparatorChar, extra["area"], viewName),
string.Format("{0}{1}{2}.spark", controllerName, Path.DirectorySeparatorChar, viewName),
string.Format("Shared{0}{1}.spark", Path.DirectorySeparatorChar, viewName),
+ string.Format("~{0}Areas{0}{1}{0}Views{0}{2}{0}{3}.shade", Path.DirectorySeparatorChar, extra["area"], controllerName, viewName),
+ string.Format("~{0}Areas{0}{1}{0}Views{0}Shared{0}{2}.shade", Path.DirectorySeparatorChar, extra["area"], viewName),
+ string.Format("{0}{1}{2}.shade", controllerName, Path.DirectorySeparatorChar, viewName),
+ string.Format("Shared{0}{1}.shade", Path.DirectorySeparatorChar, viewName)
}, extra);
}
return ApplyFilters(new[]
{
string.Format("{0}{1}{2}.spark", controllerName,Path.DirectorySeparatorChar, viewName),
- string.Format("Shared{0}{1}.spark", Path.DirectorySeparatorChar,viewName)
+ string.Format("Shared{0}{1}.spark", Path.DirectorySeparatorChar,viewName),
+ string.Format("{0}{1}{2}.shade", controllerName,Path.DirectorySeparatorChar, viewName),
+ string.Format("Shared{0}{1}.shade", Path.DirectorySeparatorChar,viewName)
}, extra);
}
@@ -216,12 +222,18 @@ protected virtual IEnumerable<string> PotentialMasterLocations(string masterName
string.Format("~{0}Areas{0}{1}{0}Views{0}Shared{0}{2}.spark", Path.DirectorySeparatorChar, extra["area"], masterName),
string.Format("Layouts{0}{1}.spark", Path.DirectorySeparatorChar,masterName),
string.Format("Shared{0}{1}.spark", Path.DirectorySeparatorChar,masterName),
+ string.Format("~{0}Areas{0}{1}{0}Views{0}Layouts{0}{2}.shade", Path.DirectorySeparatorChar, extra["area"], masterName),
+ string.Format("~{0}Areas{0}{1}{0}Views{0}Shared{0}{2}.shade", Path.DirectorySeparatorChar, extra["area"], masterName),
+ string.Format("Layouts{0}{1}.shade", Path.DirectorySeparatorChar,masterName),
+ string.Format("Shared{0}{1}.shade", Path.DirectorySeparatorChar,masterName)
}, extra);
}
return ApplyFilters(new[]
{
string.Format("Layouts{0}{1}.spark", Path.DirectorySeparatorChar,masterName),
string.Format("Shared{0}{1}.spark", Path.DirectorySeparatorChar,masterName),
+ string.Format("Layouts{0}{1}.shade", Path.DirectorySeparatorChar,masterName),
+ string.Format("Shared{0}{1}.shade", Path.DirectorySeparatorChar,masterName)
}, extra);
}
@@ -239,6 +251,14 @@ protected virtual IEnumerable<string> PotentialDefaultMasterLocations(string con
string.Format("~{0}Areas{0}{1}{0}Views{0}Shared{0}Application.spark", Path.DirectorySeparatorChar, extra["area"]),
string.Format("Layouts{0}Application.spark", Path.DirectorySeparatorChar),
string.Format("Shared{0}Application.spark", Path.DirectorySeparatorChar),
+ string.Format("~{0}Areas{0}{1}{0}Views{0}Layouts{0}{2}.shade", Path.DirectorySeparatorChar, extra["area"], controllerName),
+ string.Format("~{0}Areas{0}{1}{0}Views{0}Shared{0}{2}.shade", Path.DirectorySeparatorChar, extra["area"], controllerName),
+ string.Format("Layouts{0}{1}.shade", Path.DirectorySeparatorChar, controllerName),
+ string.Format("Shared{0}{1}.shade", Path.DirectorySeparatorChar, controllerName),
+ string.Format("~{0}Areas{0}{1}{0}Views{0}Layouts{0}Application.shade", Path.DirectorySeparatorChar, extra["area"]),
+ string.Format("~{0}Areas{0}{1}{0}Views{0}Shared{0}Application.shade", Path.DirectorySeparatorChar, extra["area"]),
+ string.Format("Layouts{0}Application.shade", Path.DirectorySeparatorChar),
+ string.Format("Shared{0}Application.shade", Path.DirectorySeparatorChar)
}, extra);
}
@@ -247,7 +267,11 @@ protected virtual IEnumerable<string> PotentialDefaultMasterLocations(string con
string.Format("Layouts{0}{1}.spark", Path.DirectorySeparatorChar, controllerName),
string.Format("Shared{0}{1}.spark", Path.DirectorySeparatorChar, controllerName),
string.Format("Layouts{0}Application.spark", Path.DirectorySeparatorChar),
- string.Format("Shared{0}Application.spark", Path.DirectorySeparatorChar)
+ string.Format("Shared{0}Application.spark", Path.DirectorySeparatorChar),
+ string.Format("Layouts{0}{1}.shade", Path.DirectorySeparatorChar, controllerName),
+ string.Format("Shared{0}{1}.shade", Path.DirectorySeparatorChar, controllerName),
+ string.Format("Layouts{0}Application.shade", Path.DirectorySeparatorChar),
+ string.Format("Shared{0}Application.shade", Path.DirectorySeparatorChar)
}, extra);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.