Cleanup - kill IsInRecycleBin and trust Trashed
This commit is contained in:
@@ -366,22 +366,6 @@ namespace Umbraco.Core.Models
|
||||
}
|
||||
#endregion
|
||||
|
||||
internal static bool IsInRecycleBin(this IContent content)
|
||||
{
|
||||
return IsInRecycleBin(content, Constants.System.RecycleBinContent);
|
||||
}
|
||||
|
||||
internal static bool IsInRecycleBin(this IMedia media)
|
||||
{
|
||||
return IsInRecycleBin(media, Constants.System.RecycleBinMedia);
|
||||
}
|
||||
|
||||
internal static bool IsInRecycleBin(this IContentBase content, int recycleBinId)
|
||||
{
|
||||
return content.Path.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Contains(recycleBinId.ToInvariantString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes characters that are not valide XML characters from all entity properties
|
||||
/// of type string. See: http://stackoverflow.com/a/961504/5018
|
||||
|
||||
@@ -37,50 +37,6 @@ namespace Umbraco.Tests.Models
|
||||
|
||||
}
|
||||
|
||||
[TestCase("-1,-20,12,34,56", false)]
|
||||
[TestCase("-1,-21,12,34,56", true)]
|
||||
[TestCase("-1,12,34,56", false)]
|
||||
public void Is_Media_In_Recycle_Bin(string path, bool isInBin)
|
||||
{
|
||||
var mediaType = MockedContentTypes.CreateImageMediaType();
|
||||
var media = MockedMedia.CreateMediaFile(mediaType, -1);
|
||||
|
||||
// this is NOT how we should do it, we should "move to recycle bin"
|
||||
// as it causes various things to change... IsInRecycleBin looks for
|
||||
// the path but Trashed looks for the flag!
|
||||
// fixme .Trashed is weird anyways, should be refactored
|
||||
media.Path = path;
|
||||
((Media)media).Trashed = isInBin;
|
||||
|
||||
media.Id = 34;
|
||||
|
||||
Assert.AreEqual(isInBin, media.IsInRecycleBin());
|
||||
if (isInBin)
|
||||
Assert.IsTrue(media.Trashed);
|
||||
}
|
||||
|
||||
[TestCase("-1,-20,12,34,56", true)]
|
||||
[TestCase("-1,-21,12,34,56", false)]
|
||||
[TestCase("-1,12,34,56", false)]
|
||||
public void Is_Content_In_Recycle_Bin(string path, bool isInBin)
|
||||
{
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType();
|
||||
var content = MockedContent.CreateSimpleContent(contentType);
|
||||
|
||||
// this is NOT how we should do it, we should "move to recycle bin"
|
||||
// as it causes various things to change... IsInRecycleBin looks for
|
||||
// the path but Trashed looks for the flag!
|
||||
// fixme .Trashed is weird anyways, should be refactored
|
||||
content.Path = path;
|
||||
content.Trashed = isInBin;
|
||||
|
||||
content.Id = 34;
|
||||
|
||||
Assert.AreEqual(isInBin, content.IsInRecycleBin());
|
||||
if (isInBin)
|
||||
Assert.IsTrue(content.Trashed);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Get_Non_Grouped_Properties()
|
||||
{
|
||||
|
||||
@@ -1384,7 +1384,7 @@ namespace Umbraco.Tests.Services
|
||||
Umbraco.Core.Configuration.GlobalSettings.UmbracoConnectionName,
|
||||
TestObjects.GetDefaultSqlSyntaxProviders(Logger),
|
||||
Logger,
|
||||
new TestScopeContextAdapter(),
|
||||
new TestScopeContextAdapter(),
|
||||
MappingResolver);
|
||||
var repositoryFactory = MockRepositoryFactory();
|
||||
var provider = new NPocoUnitOfWorkProvider(databaseFactory, repositoryFactory);
|
||||
|
||||
@@ -431,7 +431,7 @@ namespace Umbraco.Web.Editors
|
||||
}
|
||||
|
||||
//if the current item is in the recycle bin
|
||||
if (foundContent.IsInRecycleBin() == false)
|
||||
if (foundContent.Trashed == false)
|
||||
{
|
||||
var moveResult = Services.ContentService.WithResult().MoveToRecycleBin(foundContent, Security.GetUserId());
|
||||
if (moveResult == false)
|
||||
|
||||
@@ -237,7 +237,7 @@ namespace Umbraco.Web.Editors
|
||||
}
|
||||
|
||||
//if the current item is in the recycle bin
|
||||
if (foundMedia.IsInRecycleBin() == false)
|
||||
if (foundMedia.Trashed == false)
|
||||
{
|
||||
var moveResult = Services.MediaService.WithResult().MoveToRecycleBin(foundMedia, (int)Security.CurrentUser.Id);
|
||||
if (moveResult == false)
|
||||
|
||||
Reference in New Issue
Block a user