add isAdmin to user model (#6231)
update vendor and add tests fix swagger
This commit is contained in:
parent
8e202e28ad
commit
141c58f5a6
6 changed files with 28 additions and 2 deletions
|
@ -211,6 +211,7 @@ func (u *User) APIFormat() *api.User {
|
|||
Email: u.getEmail(),
|
||||
AvatarURL: u.AvatarLink(),
|
||||
Language: u.Language,
|
||||
IsAdmin: u.IsAdmin,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,23 @@ func TestGetUserEmailsByNames(t *testing.T) {
|
|||
assert.Equal(t, []string{"user8@example.com", "user5@example.com"}, GetUserEmailsByNames([]string{"user8", "user5"}))
|
||||
}
|
||||
|
||||
func TestUser_APIFormat(t *testing.T) {
|
||||
|
||||
user, err := GetUserByID(1)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, user.IsAdmin)
|
||||
|
||||
apiUser := user.APIFormat()
|
||||
assert.True(t, apiUser.IsAdmin)
|
||||
|
||||
user, err = GetUserByID(2)
|
||||
assert.NoError(t, err)
|
||||
assert.False(t, user.IsAdmin)
|
||||
|
||||
apiUser = user.APIFormat()
|
||||
assert.False(t, apiUser.IsAdmin)
|
||||
}
|
||||
|
||||
func TestCanCreateOrganization(t *testing.T) {
|
||||
assert.NoError(t, PrepareTestDatabase())
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue