feat(ui): add links to review request targets in issue comments (#8239)

- Add links to review request targets in issue comments
- Fix links to ghost users/orgs/teams to be empty

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8239
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: Robert Wolff <mahlzahn@posteo.de>
Co-committed-by: Robert Wolff <mahlzahn@posteo.de>
This commit is contained in:
Robert Wolff 2025-07-23 04:45:58 +02:00 committed by Gusted
commit 7643bdd2b5
11 changed files with 256 additions and 21 deletions

View file

@ -1,4 +1,5 @@
// Copyright 2017 The Gitea Authors. All rights reserved.
// Copyright 2025 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package organization_test
@ -15,14 +16,33 @@ import (
"github.com/stretchr/testify/require"
)
func TestTeam_IsOwnerTeam(t *testing.T) {
func TestTeam(t *testing.T) {
require.NoError(t, unittest.PrepareTestDatabase())
team := unittest.AssertExistsAndLoadBean(t, &organization.Team{ID: 1})
assert.True(t, team.IsOwnerTeam())
owners := unittest.AssertExistsAndLoadBean(t, &organization.Team{ID: 1})
assert.Equal(t, int64(3), owners.GetOrg(db.DefaultContext).ID)
assert.Equal(t, "/org/org3/teams/Owners", owners.Link(db.DefaultContext))
assert.False(t, owners.IsGhost())
assert.True(t, owners.IsOwnerTeam())
team = unittest.AssertExistsAndLoadBean(t, &organization.Team{ID: 2})
assert.False(t, team.IsOwnerTeam())
team1 := unittest.AssertExistsAndLoadBean(t, &organization.Team{ID: 2})
assert.Equal(t, int64(3), team1.GetOrg(db.DefaultContext).ID)
assert.Equal(t, "/org/org3/teams/team1", team1.Link(db.DefaultContext))
assert.False(t, team1.IsGhost())
assert.False(t, team1.IsOwnerTeam())
ghost := organization.NewGhostTeam()
assert.Equal(t, int64(-1), ghost.ID)
assert.Equal(t, int64(-1), ghost.GetOrg(db.DefaultContext).ID)
assert.Empty(t, ghost.Link(db.DefaultContext))
assert.True(t, ghost.IsGhost())
assert.False(t, ghost.IsOwnerTeam())
ghosted := organization.Team{ID: 10, Name: "Ghosted"}
assert.Equal(t, int64(-1), ghosted.GetOrg(db.DefaultContext).ID)
assert.Empty(t, ghosted.Link(db.DefaultContext))
assert.False(t, ghosted.IsGhost())
assert.False(t, ghosted.IsOwnerTeam())
}
func TestTeam_IsMember(t *testing.T) {