summaryrefslogtreecommitdiffstats
path: root/app/post_test.go
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2017-07-04 15:17:54 -0400
committerJoram Wilander <jwawilander@gmail.com>2017-07-04 15:17:54 -0400
commit4bd7b68b24137a9f8fe0abc908831cf95bb6c32b (patch)
treef8f7e906e7cf66d4f75f79c3bb599acf9ad2af63 /app/post_test.go
parent1858fba7d48d4d09094ad1e8ea04a5f2720bd11a (diff)
downloadchat-4bd7b68b24137a9f8fe0abc908831cf95bb6c32b.tar.gz
chat-4bd7b68b24137a9f8fe0abc908831cf95bb6c32b.tar.bz2
chat-4bd7b68b24137a9f8fe0abc908831cf95bb6c32b.zip
PLT-6960 Only update post.EditAt when the message changes (#6840)
Diffstat (limited to 'app/post_test.go')
-rw-r--r--app/post_test.go40
1 files changed, 33 insertions, 7 deletions
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 {