teams: local access to bus, moving away from dep on global.

This commit is contained in:
Leonard Gram
2019-03-19 14:01:20 +01:00
parent 6589a4e55f
commit adf0390b2c
5 changed files with 29 additions and 29 deletions
+1 -1
View File
@@ -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
}
+4 -4
View File
@@ -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)
})
})