Skip to content

Commit

Permalink
HOME-1781: added role id to group field (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
VSevostianov authored Oct 9, 2024
1 parent 0298d0f commit ed04912
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
3 changes: 2 additions & 1 deletion svc_teamusergroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ type NewGroup struct {
// IsAdmin is deprecated, and will be removed in next release. Use AdminRights for more granular control.
IsAdmin bool `json:"is_admin"`
// IsReviewer is deprecated, and will be removed in next release. Use the appropriate permissions in AdminRights instead.
IsReviewer bool `json:"is_reviewer"`
IsReviewer bool `json:"is_reviewer"`
RoleId int64 `json:"role_id,omitempty"`

// Possible values are activity, branches_main_modify, branches_create, branches_merge, statistics, tasks, contributors, settings, manage_languages, download, upload, glossary_delete, glossary_edit, manage_keys, screenshots, custom_status_modify, review
AdminRights []string `json:"admin_rights,omitempty"`
Expand Down
58 changes: 58 additions & 0 deletions svc_teamusergroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,64 @@ func TestTeamUserGroupService_Create(t *testing.T) {
}
}

func TestTeamUserGroupService_CreateWithRoleId(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

mux.HandleFunc(
fmt.Sprintf("/teams/%d/groups", 444),
func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
testMethod(t, r, "POST")
testHeader(t, r, apiTokenHeader, testApiToken)
data := `{
"name": "Proofreaders",
"is_admin": false,
"is_reviewer": true,
"role_id": 3,
"languages": {
"reference": [],
"contributable": [640]
}
}`

req := new(bytes.Buffer)
_ = json.Compact(req, []byte(data))

testBody(t, r, req.String())

_, _ = fmt.Fprint(w, `{
"team_id": 444,
"group": {
"group_id": 50031
}
}`)
})

r, err := client.TeamUserGroups().Create(444, NewGroup{
Name: "Proofreaders",
IsAdmin: false,
IsReviewer: true,
AdminRights: nil,
RoleId: 3,
Languages: NewGroupLanguages{
Reference: []int64{},
Contributable: []int64{640},
},
})
if err != nil {
t.Errorf("TeamUserGroups.Create returned error: %v", err)
}

want := TeamUserGroup{
GroupID: 50031,
}

if !reflect.DeepEqual(r.Group, want) {
t.Errorf("TeamUserGroups.Create returned %+v, want %+v", r.Group, want)
}
}

func TestTeamUserGroupService_Delete(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
Expand Down

0 comments on commit ed04912

Please sign in to comment.