mirror of
https://github.com/go-gitea/gitea
synced 2024-11-01 07:44:25 +00:00
22a0636544
You can limit or hide organisations. This pull make it also posible for users - new strings to translte - add checkbox to user profile form - add checkbox to admin user.edit form - filter explore page user search - filter api admin and public user searches - allow admins view "hidden" users - add app option DEFAULT_USER_VISIBILITY - rewrite many files to use Visibility field - check for teams intersection - fix context output - right fake 404 if not visible Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Andrew Thornton <art27@cantab.net>
39 lines
1.1 KiB
Go
39 lines
1.1 KiB
Go
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package convert
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"code.gitea.io/gitea/models"
|
|
api "code.gitea.io/gitea/modules/structs"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestUser_ToUser(t *testing.T) {
|
|
assert.NoError(t, models.PrepareTestDatabase())
|
|
|
|
user1 := models.AssertExistsAndLoadBean(t, &models.User{ID: 1, IsAdmin: true}).(*models.User)
|
|
|
|
apiUser := toUser(user1, true, true)
|
|
assert.True(t, apiUser.IsAdmin)
|
|
|
|
user2 := models.AssertExistsAndLoadBean(t, &models.User{ID: 2, IsAdmin: false}).(*models.User)
|
|
|
|
apiUser = toUser(user2, true, true)
|
|
assert.False(t, apiUser.IsAdmin)
|
|
|
|
apiUser = toUser(user1, false, false)
|
|
assert.False(t, apiUser.IsAdmin)
|
|
assert.EqualValues(t, api.VisibleTypePublic.String(), apiUser.Visibility)
|
|
|
|
user31 := models.AssertExistsAndLoadBean(t, &models.User{ID: 31, IsAdmin: false, Visibility: api.VisibleTypePrivate}).(*models.User)
|
|
|
|
apiUser = toUser(user31, true, true)
|
|
assert.False(t, apiUser.IsAdmin)
|
|
assert.EqualValues(t, api.VisibleTypePrivate.String(), apiUser.Visibility)
|
|
}
|