Skip to content

Commit 54e97fc

Browse files
committed
Fixed #58
1 parent 2ab7540 commit 54e97fc

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/LinkDotNet.Blog.Web/Features/Admin/BlogPostEditor/Components/CreateNewModel.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ public static CreateNewModel FromBlogPost(BlogPost blogPost)
4949
public BlogPost ToBlogPost()
5050
{
5151
var tags = string.IsNullOrWhiteSpace(Tags) ? ArraySegment<string>.Empty : Tags.Split(",");
52-
DateTime? updatedDate = ShouldUpdateDate ? null : OriginalUpdatedDate;
52+
DateTime? updatedDate = ShouldUpdateDate || OriginalUpdatedDate == default
53+
? null
54+
: OriginalUpdatedDate;
5355

5456
var blogPost = BlogPost.Create(Title, ShortDescription, Content, PreviewImageUrl, IsPublished, updatedDate, tags);
5557
blogPost.Id = Id;

tests/LinkDotNet.Blog.UnitTests/Web/Features/Admin/BlogPostEditor/Components/CreateNewBlogPostTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public void ShouldCreateNewBlogPostWhenValidDataGiven()
3636
blogPost.Content.Should().Be("My content");
3737
blogPost.PreviewImageUrl.Should().Be("My preview url");
3838
blogPost.IsPublished.Should().BeFalse();
39+
blogPost.UpdatedDate.Should().NotBe(default);
3940
blogPost.Tags.Should().HaveCount(3);
4041
blogPost.Tags.Select(t => t.Content).Should().Contain(new[] { "Tag1", "Tag2", "Tag3" });
4142
}

0 commit comments

Comments
 (0)