From 4bd7b68b24137a9f8fe0abc908831cf95bb6c32b Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Tue, 4 Jul 2017 15:17:54 -0400 Subject: PLT-6960 Only update post.EditAt when the message changes (#6840) --- app/post_test.go | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) (limited to 'app/post_test.go') diff --git a/app/post_test.go b/app/post_test.go index 9bc5ee742..416fbfc9e 100644 --- a/app/post_test.go +++ b/app/post_test.go @@ -5,11 +5,37 @@ package app import ( "testing" + "time" - "github.com/mattermost/platform/model" "fmt" + "github.com/mattermost/platform/model" ) +func TestUpdatePostEditAt(t *testing.T) { + th := Setup().InitBasic() + + post := &model.Post{} + *post = *th.BasicPost + + post.IsPinned = true + if saved, err := UpdatePost(post, true); err != nil { + t.Fatal(err) + } else if saved.EditAt != post.EditAt { + t.Fatal("shouldn't have updated post.EditAt when pinning post") + + *post = *saved + } + + time.Sleep(time.Millisecond * 100) + + post.Message = model.NewId() + if saved, err := UpdatePost(post, true); err != nil { + t.Fatal(err) + } else if saved.EditAt == post.EditAt { + t.Fatal("should have updated post.EditAt when updating post message") + } +} + func TestPostReplyToPostWhereRootPosterLeftChannel(t *testing.T) { // This test ensures that when replying to a root post made by a user who has since left the channel, the reply // post completes successfully. This is a regression test for PLT-6523. @@ -29,13 +55,13 @@ func TestPostReplyToPostWhereRootPosterLeftChannel(t *testing.T) { } replyPost := model.Post{ - Message: "asd", - ChannelId: channel.Id, - RootId: rootPost.Id, - ParentId: rootPost.Id, + Message: "asd", + ChannelId: channel.Id, + RootId: rootPost.Id, + ParentId: rootPost.Id, PendingPostId: model.NewId() + ":" + fmt.Sprint(model.GetMillis()), - UserId: userInChannel.Id, - CreateAt: 0, + UserId: userInChannel.Id, + CreateAt: 0, } if _, err := CreatePostAsUser(&replyPost); err != nil { -- cgit v1.2.3-1-g7c22