mirror of
https://github.com/go-gitea/gitea.git
synced 2024-12-12 17:43:54 +08:00
fe49cb0243
This PR rewrites `GetReviewer` function and move it to service layer. Reviewers should not be watchers, so that this PR removed all watchers from reviewers. When the repository is under an organization, the pull request unit read permission will be checked to resolve the bug of #32394 Fix #32394
32 lines
945 B
Go
32 lines
945 B
Go
// Copyright 2024 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package organization_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"code.gitea.io/gitea/models/db"
|
|
"code.gitea.io/gitea/models/organization"
|
|
"code.gitea.io/gitea/models/perm"
|
|
"code.gitea.io/gitea/models/repo"
|
|
"code.gitea.io/gitea/models/unit"
|
|
"code.gitea.io/gitea/models/unittest"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestGetTeamsWithAccessToRepoUnit(t *testing.T) {
|
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
|
|
|
org41 := unittest.AssertExistsAndLoadBean(t, &organization.Organization{ID: 41})
|
|
repo61 := unittest.AssertExistsAndLoadBean(t, &repo.Repository{ID: 61})
|
|
|
|
teams, err := organization.GetTeamsWithAccessToRepoUnit(db.DefaultContext, org41.ID, repo61.ID, perm.AccessModeRead, unit.TypePullRequests)
|
|
assert.NoError(t, err)
|
|
if assert.Len(t, teams, 2) {
|
|
assert.EqualValues(t, 21, teams[0].ID)
|
|
assert.EqualValues(t, 22, teams[1].ID)
|
|
}
|
|
}
|