mirror of
https://github.com/interviewstreet/go-jira.git
synced 2025-12-01 22:30:28 +02:00
Add UpdateAssignee method to allow users to change issue assignee
This commit is contained in:
19
issue.go
19
issue.go
@@ -1088,3 +1088,22 @@ func (s *IssueService) RemoveWatcher(issueID string, userName string) (*Response
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
// UpdateAssignee updates the user assigned to work on the given issue
|
||||
//
|
||||
// JIRA API docs: https://docs.atlassian.com/software/jira/docs/api/REST/7.10.2/#api/2/issue-assign
|
||||
func (s *IssueService) UpdateAssignee(issueID string, assignee *User) (*Response, error) {
|
||||
apiEndPoint := fmt.Sprintf("rest/api/2/issue/%s/assignee", issueID)
|
||||
|
||||
req, err := s.client.NewRequest("PUT", apiEndPoint, assignee)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := s.client.Do(req, nil)
|
||||
if err != nil {
|
||||
err = NewJiraError(resp, err)
|
||||
}
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
@@ -1308,3 +1308,25 @@ func TestIssueService_GetWatchers(t *testing.T) {
|
||||
t.Error("Expected watcher name fred")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssueService_UpdateAssignee(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
testMux.HandleFunc("/rest/api/2/issue/10002/assignee", func(w http.ResponseWriter, r *http.Request) {
|
||||
testMethod(t, r, "PUT")
|
||||
testRequestURL(t, r, "/rest/api/2/issue/10002/assignee")
|
||||
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
})
|
||||
|
||||
resp, err := testClient.Issue.UpdateAssignee("10002", &User{
|
||||
Name: "test-username",
|
||||
})
|
||||
|
||||
if resp.StatusCode != 204 {
|
||||
t.Error("Expected issue not re-assigned.")
|
||||
}
|
||||
if err != nil {
|
||||
t.Errorf("Error given: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user