Convey("When user is editor and in the ACL",func(){
loggedInUserScenarioWithRole("When calling GET on","GET","/api/dashboards/id/1/acl","/api/dashboards/id/:dashboardId/acl",models.ROLE_EDITOR,func(sc*scenarioContext){
ifres,err:=sess.Query("SELECT 1 from "+dialect.Quote("dashboard_acl")+" WHERE dashboard_id =? and (user_group_id=? or user_id=?)",cmd.DashboardId,cmd.UserGroupId,cmd.UserId);err!=nil{
returnerr
}elseiflen(res)==1{
entity:=m.DashboardAcl{
Permissions:cmd.Permissions,
Permission:cmd.Permission,
Updated:time.Now(),
}
if_,err:=sess.Cols("updated","permissions").Where("dashboard_id =? and (user_group_id=? or user_id=?)",cmd.DashboardId,cmd.UserGroupId,cmd.UserId).Update(&entity);err!=nil{
if_,err:=sess.Cols("updated","permission").Where("dashboard_id =? and (user_group_id=? or user_id=?)",cmd.DashboardId,cmd.UserGroupId,cmd.UserId).Update(&entity);err!=nil{