summaryrefslogtreecommitdiffstats
path: root/models/user_test.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-11-22 23:21:55 +0800
committerGitHub <noreply@github.com>2021-11-22 23:21:55 +0800
commitbaed01f24753afb600a2984dcb9bcda0bb8502b6 (patch)
tree5621ef980b6b0067a21c86be7e4808d83c0538ab /models/user_test.go
parentc2ab19888f92fbdec4276a16d224e8de80d1d1dd (diff)
downloadgitea-baed01f24753afb600a2984dcb9bcda0bb8502b6.tar.gz
gitea-baed01f24753afb600a2984dcb9bcda0bb8502b6.zip
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
Diffstat (limited to 'models/user_test.go')
-rw-r--r--models/user_test.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/models/user_test.go b/models/user_test.go
index 7f29f5c849..cfbd849640 100644
--- a/models/user_test.go
+++ b/models/user_test.go
@@ -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())
}
}