mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-17 15:32:43 +00:00
Remove unnecessary attributes of User struct (#17745)
* Remove unnecessary functions of User struct * Move more database methods out of user struct * Move more database methods out of user struct * Fix template failure * Fix bug * Remove finished FIXME * remove unnecessary code
This commit is contained in:
parent
c2ab19888f
commit
baed01f247
42 changed files with 279 additions and 451 deletions
|
@ -52,7 +52,9 @@ func TestUserIsPublicMember(t *testing.T) {
|
|||
func testUserIsPublicMember(t *testing.T, uid, orgID int64, expected bool) {
|
||||
user, err := GetUserByID(uid)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, expected, user.IsPublicMember(orgID))
|
||||
is, err := IsPublicMembership(orgID, user.ID)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, expected, is)
|
||||
}
|
||||
|
||||
func TestIsUserOrgOwner(t *testing.T) {
|
||||
|
@ -78,7 +80,9 @@ func TestIsUserOrgOwner(t *testing.T) {
|
|||
func testIsUserOrgOwner(t *testing.T, uid, orgID int64, expected bool) {
|
||||
user, err := GetUserByID(uid)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, expected, user.IsUserOrgOwner(orgID))
|
||||
is, err := IsOrganizationOwner(orgID, user.ID)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, expected, is)
|
||||
}
|
||||
|
||||
func TestGetUserEmailsByNames(t *testing.T) {
|
||||
|
@ -198,13 +202,13 @@ func TestEmailNotificationPreferences(t *testing.T) {
|
|||
assert.Equal(t, test.expected, user.EmailNotifications())
|
||||
|
||||
// Try all possible settings
|
||||
assert.NoError(t, user.SetEmailNotifications(EmailNotificationsEnabled))
|
||||
assert.NoError(t, SetEmailNotifications(user, EmailNotificationsEnabled))
|
||||
assert.Equal(t, EmailNotificationsEnabled, user.EmailNotifications())
|
||||
|
||||
assert.NoError(t, user.SetEmailNotifications(EmailNotificationsOnMention))
|
||||
assert.NoError(t, SetEmailNotifications(user, EmailNotificationsOnMention))
|
||||
assert.Equal(t, EmailNotificationsOnMention, user.EmailNotifications())
|
||||
|
||||
assert.NoError(t, user.SetEmailNotifications(EmailNotificationsDisabled))
|
||||
assert.NoError(t, SetEmailNotifications(user, EmailNotificationsDisabled))
|
||||
assert.Equal(t, EmailNotificationsDisabled, user.EmailNotifications())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue