teams: local access to bus, moving away from dep on global.
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
m "github.com/grafana/grafana/pkg/models"
|
||||
)
|
||||
|
||||
func CanAdmin(orgId int64, teamId int64, user *m.SignedInUser) error {
|
||||
func CanAdmin(bus bus.Bus, orgId int64, teamId int64, user *m.SignedInUser) error {
|
||||
if user.OrgRole == m.ROLE_ADMIN {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ func TestUpdateTeam(t *testing.T) {
|
||||
return nil
|
||||
})
|
||||
|
||||
err := CanAdmin(testTeam.OrgId, testTeam.Id, &editor)
|
||||
err := CanAdmin(bus.GetBus(), testTeam.OrgId, testTeam.Id, &editor)
|
||||
So(err, ShouldEqual, m.ErrNotAllowedToUpdateTeam)
|
||||
})
|
||||
})
|
||||
@@ -50,7 +50,7 @@ func TestUpdateTeam(t *testing.T) {
|
||||
return nil
|
||||
})
|
||||
|
||||
err := CanAdmin(testTeam.OrgId, testTeam.Id, &editor)
|
||||
err := CanAdmin(bus.GetBus(), testTeam.OrgId, testTeam.Id, &editor)
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
})
|
||||
@@ -72,14 +72,14 @@ func TestUpdateTeam(t *testing.T) {
|
||||
return nil
|
||||
})
|
||||
|
||||
err := CanAdmin(testTeamOtherOrg.OrgId, testTeamOtherOrg.Id, &editor)
|
||||
err := CanAdmin(bus.GetBus(), testTeamOtherOrg.OrgId, testTeamOtherOrg.Id, &editor)
|
||||
So(err, ShouldEqual, m.ErrNotAllowedToUpdateTeamInDifferentOrg)
|
||||
})
|
||||
})
|
||||
|
||||
Convey("Given an org admin and a team", func() {
|
||||
Convey("Should be able to update the team", func() {
|
||||
err := CanAdmin(testTeam.OrgId, testTeam.Id, &admin)
|
||||
err := CanAdmin(bus.GetBus(), testTeam.OrgId, testTeam.Id, &admin)
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user