Fixes a couple issues with some routing tests.
This commit is contained in:
@@ -38,6 +38,7 @@ namespace Umbraco.Tests.Routing
|
||||
public override void TearDown()
|
||||
{
|
||||
base.TearDown();
|
||||
UmbracoContext.Current = null;
|
||||
RouteTable.Routes.Clear();
|
||||
System.Configuration.ConfigurationManager.AppSettings.Set("umbracoPath", "");
|
||||
SurfaceControllerResolver.Reset();
|
||||
@@ -97,7 +98,7 @@ namespace Umbraco.Tests.Routing
|
||||
var template = CreateTemplate(templateName);
|
||||
var route = RouteTable.Routes["Umbraco_default"];
|
||||
var routeData = new RouteData() {Route = route};
|
||||
var routingContext = GetRoutingContext("~/dummy-page", template.Id, routeData);
|
||||
var routingContext = GetRoutingContext("~/dummy-page", template.Id, routeData, true);
|
||||
var docRequest = new PublishedContentRequest(routingContext.UmbracoContext.CleanedUmbracoUrl, routingContext)
|
||||
{
|
||||
PublishedContent = routingContext.PublishedContentStore.GetDocumentById(routingContext.UmbracoContext, 1172),
|
||||
|
||||
@@ -25,17 +25,18 @@ namespace Umbraco.Tests.TestHelpers
|
||||
ConfigurationManager.AppSettings.Set("umbracoHideTopLevelNodeFromPath", "");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a new RoutingContext
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="templateId">
|
||||
/// The template Id to insert into the Xml cache file for each node, this is helpful for unit testing with templates but you
|
||||
/// should normally create the template in the database with this id
|
||||
///</param>
|
||||
/// <param name="routeData"></param>
|
||||
/// <returns></returns>
|
||||
protected RoutingContext GetRoutingContext(string url, int templateId, RouteData routeData = null)
|
||||
/// <summary>
|
||||
/// Return a new RoutingContext
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="templateId">
|
||||
/// The template Id to insert into the Xml cache file for each node, this is helpful for unit testing with templates but you
|
||||
/// should normally create the template in the database with this id
|
||||
/// </param>
|
||||
/// <param name="routeData"></param>
|
||||
/// <param name="setUmbracoContextCurrent">set to true to also set the singleton UmbracoContext.Current to the context created with this method</param>
|
||||
/// <returns></returns>
|
||||
protected RoutingContext GetRoutingContext(string url, int templateId, RouteData routeData = null, bool setUmbracoContextCurrent = false)
|
||||
{
|
||||
var umbracoContext = GetUmbracoContext(url, templateId, routeData);
|
||||
var contentStore = new DefaultPublishedContentStore();
|
||||
@@ -51,6 +52,9 @@ namespace Umbraco.Tests.TestHelpers
|
||||
//assign the routing context back to the umbraco context
|
||||
umbracoContext.RoutingContext = routingContext;
|
||||
|
||||
if (setUmbracoContextCurrent)
|
||||
UmbracoContext.Current = umbracoContext;
|
||||
|
||||
return routingContext;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,12 @@ namespace Umbraco.Web.Mvc
|
||||
{
|
||||
ActionInvoker = new RenderActionInvoker();
|
||||
}
|
||||
|
||||
public RenderMvcController(UmbracoContext umbracoContext)
|
||||
: base(umbracoContext)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private PublishedContentRequest _publishedContentRequest;
|
||||
|
||||
|
||||
@@ -232,7 +232,7 @@ namespace Umbraco.Web.Mvc
|
||||
var def = new RouteDefinition
|
||||
{
|
||||
ControllerName = defaultControllerName,
|
||||
Controller = new RenderMvcController(),
|
||||
Controller = new RenderMvcController(UmbracoContext),
|
||||
PublishedContentRequest = publishedContentRequest,
|
||||
ActionName = ((Route)requestContext.RouteData.Route).Defaults["action"].ToString(),
|
||||
HasHijackedRoute = false
|
||||
|
||||
Reference in New Issue
Block a user