Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HOME-1781: added role id to group field #55

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading