Fixes up logic for creating new versions (U4-2589 Save and Publish is not creating version of document)

This commit is contained in:
Shannon
2013-08-08 10:42:06 +10:00
parent 5fce741940
commit 0fbc32a87f
3 changed files with 72 additions and 15 deletions

View File

@@ -9,15 +9,29 @@ namespace Umbraco.Tests.Models
public class ContentExtensionsTests
{
[Test]
public void Should_Create_New_Version_When_Publish_Status_Changed()
public void Should_Create_New_Version_When_Publishing()
{
var contentType = MockedContentTypes.CreateTextpageContentType();
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
content.ResetDirtyProperties(false);
content.ChangePublishedState(PublishedState.Published);
Assert.IsTrue(content.ShouldCreateNewVersion());
}
content.Published = true;
Assert.IsTrue(content.ShouldCreateNewVersion(PublishedState.Published));
[Test]
public void Should_Create_New_Version_When_Saving_After_Publishing()
{
var contentType = MockedContentTypes.CreateTextpageContentType();
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
content.ResetDirtyProperties(false);
content.ChangePublishedState(PublishedState.Published);
content.ResetDirtyProperties(false);
content.ChangePublishedState(PublishedState.Saved);
Assert.IsTrue(content.ShouldCreateNewVersion());
}
[Test]
@@ -33,7 +47,7 @@ namespace Umbraco.Tests.Models
}
[Test]
public void Should_Create_New_Version_When_Any_Property_Value_Changed()
public void Should_Create_New_Version_When_Any_Property_Value_Changed_And_Its_Already_Published()
{
var contentType = MockedContentTypes.CreateTextpageContentType();
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
@@ -41,11 +55,11 @@ namespace Umbraco.Tests.Models
content.ResetDirtyProperties(false);
content.Properties.First().Value = "hello world";
Assert.IsTrue(content.ShouldCreateNewVersion(PublishedState.Unpublished));
Assert.IsTrue(content.ShouldCreateNewVersion(PublishedState.Published));
}
[Test]
public void Should_Not_Create_New_Version_When_Anything_Other_Than_Published_Language_Or_Property_Vals_Changed()
public void Should_Not_Create_New_Version_When_Published_Status_Not_Changed()
{
var contentType = MockedContentTypes.CreateTextpageContentType();
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
@@ -55,5 +69,19 @@ namespace Umbraco.Tests.Models
Assert.IsFalse(content.ShouldCreateNewVersion(PublishedState.Unpublished));
}
[Test]
public void Should_Not_Create_New_Version_When_Not_Published_And_Property_Changed()
{
var contentType = MockedContentTypes.CreateTextpageContentType();
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
content.ResetDirtyProperties(false);
content.Properties.First().Value = "hello world";
Assert.IsFalse(content.ShouldCreateNewVersion(PublishedState.Unpublished));
}
}
}