Make sure the author is returned when creating a new comment
This commit is contained in:
parent
1f039c4cda
commit
c551706b52
2 changed files with 6 additions and 0 deletions
|
@ -65,6 +65,10 @@ func (tc *TaskComment) Create(a web.Auth) (err error) {
|
||||||
|
|
||||||
tc.AuthorID = a.GetID()
|
tc.AuthorID = a.GetID()
|
||||||
_, err = x.Insert(tc)
|
_, err = x.Insert(tc)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tc.Author, err = user.GetUserByID(a.GetID())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,8 @@ func TestTaskComment_Create(t *testing.T) {
|
||||||
}
|
}
|
||||||
err := tc.Create(u)
|
err := tc.Create(u)
|
||||||
assert.NoError(t, err)
|
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) {
|
t.Run("nonexisting task", func(t *testing.T) {
|
||||||
db.LoadAndAssertFixtures(t)
|
db.LoadAndAssertFixtures(t)
|
||||||
|
|
Loading…
Reference in a new issue