From c551706b52c417a39ef60741a3dbf28bf4a37724 Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 25 Feb 2020 21:18:42 +0100 Subject: [PATCH] Make sure the author is returned when creating a new comment --- pkg/models/task_comments.go | 4 ++++ pkg/models/task_comments_test.go | 2 ++ 2 files changed, 6 insertions(+) diff --git a/pkg/models/task_comments.go b/pkg/models/task_comments.go index 41ae22eb06f..aa689f8023c 100644 --- a/pkg/models/task_comments.go +++ b/pkg/models/task_comments.go @@ -65,6 +65,10 @@ func (tc *TaskComment) Create(a web.Auth) (err error) { tc.AuthorID = a.GetID() _, err = x.Insert(tc) + if err != nil { + return + } + tc.Author, err = user.GetUserByID(a.GetID()) return } diff --git a/pkg/models/task_comments_test.go b/pkg/models/task_comments_test.go index 6127d2d0fd5..618761c6968 100644 --- a/pkg/models/task_comments_test.go +++ b/pkg/models/task_comments_test.go @@ -33,6 +33,8 @@ func TestTaskComment_Create(t *testing.T) { } err := tc.Create(u) assert.NoError(t, err) + assert.Equal(t, "test", tc.Comment) + assert.Equal(t, int64(1), tc.Author.ID) }) t.Run("nonexisting task", func(t *testing.T) { db.LoadAndAssertFixtures(t)