Permalink
Browse files

Fixed problem with Expires getting null value when publishing. Now if…

… Expires has a value it will be set unless re-publishing an expired item.
  • Loading branch information...
staryd authored and bherila committed Oct 30, 2017
1 parent 0d806dc commit 60cb5fbb0754ec61d157ea996a786c76e5f28897
@@ -15,8 +15,12 @@ public override void Process(CommandContext state)
state.Content.Published = Utility.CurrentTime();
}
if (state.Content.Expires.HasValue)
state.Content.Expires = null;
if (Binding.GetUpdatedDetails(state).Contains("Expires"))
return;
if (state.Content.Expires.HasValue && state.Content.Expires.Value < Utility.CurrentTime())
state.Content.Expires = null;
}
}
}
}
@@ -85,6 +85,42 @@ public void CanMoveItem_ToBefore_Item()
Assert.That(item.Children[1], Is.EqualTo(child));
}
[Test]
public void Expires_IsClearedIfExpiresHasPassed()
{
item.Expires = N2.Utility.CurrentTime().AddDays(-1);
var context = new CommandContext(definitions.GetDefinition(item.GetContentType()), item, Interfaces.Editing, CreatePrincipal("admin"), nullBinder, nullValidator);
var command = CreateCommand(context);
dispatcher.Execute(command, context);
Assert.That(context.Content.Expires, Is.Null);
}
[Test]
public void Expires_IsNotClearedIfExpiresInFuture()
{
var expireDate = N2.Utility.CurrentTime().AddDays(10);
item.Expires = expireDate;
var context = new CommandContext(definitions.GetDefinition(item.GetContentType()), item, Interfaces.Editing, CreatePrincipal("admin"), nullBinder, nullValidator);
var command = CreateCommand(context);
dispatcher.Execute(command, context);
Assert.That(context.Content.Expires, Is.EqualTo(expireDate));
}
[Test]
public void Expires_IsNotClearedIfExpiresHasPassedButIsEdited()
{
var expireDate = N2.Utility.CurrentTime().AddDays(-1);
item.Expires = expireDate;
var context = new CommandContext(definitions.GetDefinition(item.GetContentType()), item, Interfaces.Editing, CreatePrincipal("admin"), nullBinder, nullValidator);
context.Parameters.Add("UpdatedDetailsKey", new System.Collections.Generic.List<string> { "Expires" });
var command = CreateCommand(context);
dispatcher.Execute(command, context);
Assert.That(context.Content.Expires, Is.EqualTo(expireDate));
}
//What's the point, really?
//[Test]
//public void Sets_PublishedDate()

0 comments on commit 60cb5fb

Please sign in to comment.