Fixes merge issues
This commit is contained in:
@@ -10,6 +10,7 @@ using System.Xml;
|
||||
using NUnit.Framework;
|
||||
using SQLCE4Umbraco;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.ObjectResolution;
|
||||
@@ -41,6 +42,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
private static volatile bool _firstRunInTestSession = true;
|
||||
private static readonly object Locker = new object();
|
||||
private bool _firstTestInFixture = true;
|
||||
private DefaultDatabaseFactory _dbFactory;
|
||||
|
||||
//Used to flag if its the first test in the current session
|
||||
private bool _isFirstRunInTestSession = false;
|
||||
@@ -52,26 +54,16 @@ namespace Umbraco.Tests.TestHelpers
|
||||
{
|
||||
InitializeFirstRunFlags();
|
||||
|
||||
_dbFactory = new DefaultDatabaseFactory(
|
||||
GetDbConnectionString(),
|
||||
GetDbProviderName());
|
||||
|
||||
base.Initialize();
|
||||
|
||||
var path = TestHelper.CurrentAssemblyDirectory;
|
||||
AppDomain.CurrentDomain.SetData("DataDirectory", path);
|
||||
|
||||
var dbFactory = new DefaultDatabaseFactory(
|
||||
GetDbConnectionString(),
|
||||
GetDbProviderName());
|
||||
ApplicationContext.Current = new ApplicationContext(
|
||||
//assign the db context
|
||||
new DatabaseContext(dbFactory),
|
||||
//assign the service context
|
||||
new ServiceContext(new PetaPocoUnitOfWorkProvider(dbFactory), new FileUnitOfWorkProvider(), new PublishingStrategy()),
|
||||
//disable cache
|
||||
false)
|
||||
{
|
||||
IsReady = true
|
||||
};
|
||||
|
||||
DatabaseContext.Initialize(dbFactory.ProviderName, dbFactory.ConnectionString);
|
||||
DatabaseContext.Initialize(_dbFactory.ProviderName, _dbFactory.ConnectionString);
|
||||
|
||||
CreateSqlCeDatabase();
|
||||
|
||||
@@ -80,7 +72,23 @@ namespace Umbraco.Tests.TestHelpers
|
||||
//ensure the configuration matches the current version for tests
|
||||
SettingsForTests.ConfigurationStatus = UmbracoVersion.Current.ToString(3);
|
||||
}
|
||||
|
||||
|
||||
protected override void SetupApplicationContext()
|
||||
{
|
||||
//disable cache
|
||||
var cacheHelper = new CacheHelper(new NullCacheProvider(), false);
|
||||
|
||||
ApplicationContext.Current = new ApplicationContext(
|
||||
//assign the db context
|
||||
new DatabaseContext(_dbFactory),
|
||||
//assign the service context
|
||||
new ServiceContext(new PetaPocoUnitOfWorkProvider(), new FileUnitOfWorkProvider(), new PublishingStrategy(), cacheHelper),
|
||||
cacheHelper)
|
||||
{
|
||||
IsReady = true
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The database behavior to use for the test/fixture
|
||||
/// </summary>
|
||||
|
||||
@@ -161,5 +161,50 @@ namespace Umbraco.Web.Editors
|
||||
|
||||
return display;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the sort order for media
|
||||
/// </summary>
|
||||
/// <param name="sorted"></param>
|
||||
/// <returns></returns>
|
||||
public HttpResponseMessage PostSort(ContentSortOrder sorted)
|
||||
{
|
||||
if (sorted == null)
|
||||
{
|
||||
return Request.CreateResponse(HttpStatusCode.NotFound);
|
||||
}
|
||||
|
||||
//if there's nothing to sort just return ok
|
||||
if (sorted.IdSortOrder.Length == 0)
|
||||
{
|
||||
return Request.CreateResponse(HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
if (!Security.UserHasAppAccess(global::Umbraco.Core.Constants.Applications.Media, UmbracoUser))
|
||||
{
|
||||
return Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "User has no access to this application");
|
||||
}
|
||||
|
||||
var mediaService = base.ApplicationContext.Services.MediaService;
|
||||
var sortedMedia = new List<IMedia>();
|
||||
try
|
||||
{
|
||||
sortedMedia.AddRange(sorted.IdSortOrder.Select(mediaService.GetById));
|
||||
|
||||
// Save Media with new sort order and update content xml in db accordingly
|
||||
if (!mediaService.Sort(sortedMedia))
|
||||
{
|
||||
LogHelper.Warn<MediaController>("Media sorting failed, this was probably caused by an event being cancelled");
|
||||
return Request.CreateErrorResponse(HttpStatusCode.Forbidden, "Media sorting failed, this was probably caused by an event being cancelled");
|
||||
}
|
||||
return Request.CreateResponse(HttpStatusCode.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error<MediaController>("Could not update media sort order", ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,8 +57,8 @@ namespace Umbraco.Web.Mvc
|
||||
//we need to that the app is configured and that a user is logged in
|
||||
if (!appContext.IsConfigured)
|
||||
return false;
|
||||
|
||||
var isLoggedIn = umbContext.Security.ValidateCurrentUser();
|
||||
var isLoggedIn = umbCtx.Security.ValidateUserContextId(umbCtx.Security.UmbracoUserContextId);
|
||||
return isLoggedIn;
|
||||
}
|
||||
catch (Exception)
|
||||
|
||||
@@ -296,6 +296,8 @@
|
||||
<Compile Include="Cache\UserPermissionsCacheRefresher.cs" />
|
||||
<Compile Include="Cache\UserTypeCacheRefresher.cs" />
|
||||
<Compile Include="Configuration\WebRouting.cs" />
|
||||
<Compile Include="Editors\AuthenticationController.cs" />
|
||||
<Compile Include="Editors\ContentController.cs" />
|
||||
<Compile Include="Models\ContentEditing\ContentSortOrder.cs" />
|
||||
<Compile Include="Editors\ContentControllerBase.cs" />
|
||||
<Compile Include="Editors\ContentTypeController.cs" />
|
||||
|
||||
@@ -99,12 +99,5 @@ namespace Umbraco.Web.WebApi
|
||||
/// </summary>
|
||||
internal Guid InstanceId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the WebSecurity instance
|
||||
/// </summary>
|
||||
public WebSecurity Security
|
||||
{
|
||||
get { return UmbracoContext.Security; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,8 +33,6 @@ namespace Umbraco.Web.WebApi
|
||||
if (!_userisValidated)
|
||||
{
|
||||
Security.ValidateCurrentUser(true);
|
||||
throw new InvalidOperationException("To get a current user, this method must occur in a web request");
|
||||
Security.ValidateCurrentUser(ctx.Result, true);
|
||||
_userisValidated = true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user