Skip to content

Commit 9cd0f14

Browse files
committed
fix tests
1 parent b0dd3bd commit 9cd0f14

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

models/fixtures/user.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@
343343
is_admin: false
344344
avatar: avatar22
345345
avatar_email: user22@example.com
346-
num_repos: 1
346+
num_repos: 2
347347
is_active: true
348348
num_members: 0
349349
num_teams: 0
@@ -361,7 +361,7 @@
361361
is_admin: false
362362
avatar: avatar23
363363
avatar_email: user23@example.com
364-
num_repos: 1
364+
num_repos: 2
365365
is_active: true
366366
num_members: 0
367367
num_teams: 0

models/org.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,10 @@ func getOwnedOrgsByUserID(sess *xorm.Session, userID int64) ([]*User, error) {
370370

371371
// HasOrgVisible tells if the given user can see the given org
372372
func HasOrgVisible(org *User, user *User) bool {
373+
return hasOrgVisible(x, org, user)
374+
}
375+
376+
func hasOrgVisible(e Engine, org *User, user *User) bool {
373377
// Not SignedUser
374378
if user == nil {
375379
if org.Visibility == structs.VisibleTypePublic {
@@ -382,7 +386,7 @@ func HasOrgVisible(org *User, user *User) bool {
382386
return true
383387
}
384388

385-
if org.Visibility == structs.VisibleTypePrivate && !org.IsUserPartOfOrg(user.ID) {
389+
if org.Visibility == structs.VisibleTypePrivate && !org.isUserPartOfOrg(e, user.ID) {
386390
return false
387391
}
388392
return true

models/user.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,11 @@ func (u *User) IsUserOrgOwner(orgID int64) bool {
538538

539539
// IsUserPartOfOrg returns true if user with userID is part of the u organisation.
540540
func (u *User) IsUserPartOfOrg(userID int64) bool {
541-
isMember, err := IsOrganizationMember(u.ID, userID)
541+
return u.isUserPartOfOrg(x, userID)
542+
}
543+
544+
func (u *User) isUserPartOfOrg(e Engine, userID int64) bool {
545+
isMember, err := isOrganizationMember(e, u.ID, userID)
542546
if err != nil {
543547
log.Error("IsOrganizationMember: %v", err)
544548
return false

0 commit comments

Comments
 (0)