mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-02 16:49:41 +00:00
fix: represent a deleted assignee team as a Ghost team (#38413)
Fixes #35472. `Comment.LoadAssigneeUserAndTeam` already has a Ghost user fallback for a deleted assignee user, but the parallel branch for a deleted assignee team just swallowed the not-found error and left `AssigneeTeam` as `nil`. This is inconsistent (the reporter's example shows `assignee` becoming a Ghost user while `assignee_team` becomes `null`), and it's also a latent nil pointer bug: other code that assumes `AssigneeTeam` is set once this function returns without error will panic. Added `organization.NewGhostTeam()` / `Team.IsGhost()`, mirroring the existing `user_model.NewGhostUser()` / `User.IsGhost()` pattern, and used it in the same fallback branch. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
committed by
GitHub
parent
678b5aba30
commit
aba0eb1749
@@ -45,6 +45,19 @@ func TestCreateComment(t *testing.T) {
|
||||
unittest.AssertInt64InRange(t, now, then, int64(updatedIssue.UpdatedUnix))
|
||||
}
|
||||
|
||||
func TestLoadAssigneeUserAndTeam_DeletedTeamBecomesGhostTeam(t *testing.T) {
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
issue := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 15})
|
||||
comment := &issues_model.Comment{
|
||||
Type: issues_model.CommentTypeAssignees,
|
||||
IssueID: issue.ID,
|
||||
AssigneeTeamID: 999999, // non-existing team ID
|
||||
}
|
||||
assert.NoError(t, comment.LoadAssigneeUserAndTeam(t.Context()))
|
||||
assert.NotNil(t, comment.AssigneeTeam)
|
||||
assert.EqualValues(t, -1, comment.AssigneeTeam.ID)
|
||||
}
|
||||
|
||||
func Test_UpdateCommentAttachment(t *testing.T) {
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user