Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny committed Apr 25, 2019
1 parent b0dd3bd commit 9cd0f14
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions models/fixtures/user.yml
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@
is_admin: false
avatar: avatar22
avatar_email: [email protected]
num_repos: 1
num_repos: 2
is_active: true
num_members: 0
num_teams: 0
Expand All @@ -361,7 +361,7 @@
is_admin: false
avatar: avatar23
avatar_email: [email protected]
num_repos: 1
num_repos: 2
is_active: true
num_members: 0
num_teams: 0
Expand Down
6 changes: 5 additions & 1 deletion models/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,10 @@ func getOwnedOrgsByUserID(sess *xorm.Session, userID int64) ([]*User, error) {

// HasOrgVisible tells if the given user can see the given org
func HasOrgVisible(org *User, user *User) bool {
return hasOrgVisible(x, org, user)
}

func hasOrgVisible(e Engine, org *User, user *User) bool {
// Not SignedUser
if user == nil {
if org.Visibility == structs.VisibleTypePublic {
Expand All @@ -382,7 +386,7 @@ func HasOrgVisible(org *User, user *User) bool {
return true
}

if org.Visibility == structs.VisibleTypePrivate && !org.IsUserPartOfOrg(user.ID) {
if org.Visibility == structs.VisibleTypePrivate && !org.isUserPartOfOrg(e, user.ID) {
return false
}
return true
Expand Down
6 changes: 5 additions & 1 deletion models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,11 @@ func (u *User) IsUserOrgOwner(orgID int64) bool {

// IsUserPartOfOrg returns true if user with userID is part of the u organisation.
func (u *User) IsUserPartOfOrg(userID int64) bool {
isMember, err := IsOrganizationMember(u.ID, userID)
return u.isUserPartOfOrg(x, userID)
}

func (u *User) isUserPartOfOrg(e Engine, userID int64) bool {
isMember, err := isOrganizationMember(e, u.ID, userID)
if err != nil {
log.Error("IsOrganizationMember: %v", err)
return false
Expand Down

0 comments on commit 9cd0f14

Please sign in to comment.