Skip to content

Commit

Permalink
feat: provide access to issue transitions loaded from JIRA API
Browse files Browse the repository at this point in the history
JIRA API is able to provide clients with list of transitions available
for issue in its current state (https://docs.atlassian.com/software/
jira/docs/api/REST/latest/#api/2/issue-getIssue)

Go-Jira client ignored the 'transitions' information in JIRA API JSON
response. Now it provides full access to transitions available for
current user in issue's current state
  • Loading branch information
Korenevskiy Denis authored and ghostsquad committed Dec 4, 2019
1 parent 1c3507a commit 7530b7c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type Issue struct {
Fields *IssueFields `json:"fields,omitempty" structs:"fields,omitempty"`
RenderedFields *IssueRenderedFields `json:"renderedFields,omitempty" structs:"renderedFields,omitempty"`
Changelog *Changelog `json:"changelog,omitempty" structs:"changelog,omitempty"`
Transitions []Transition `json:"transitions,omitempty" structs:"transitions,omitempty"`
}

// ChangelogItems reflects one single changelog item of a history item
Expand Down
31 changes: 31 additions & 0 deletions issue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1564,6 +1564,37 @@ func TestIssueService_Get_Fields_Changelog(t *testing.T) {
t.Errorf("Expected CreatedTime func return %v time, %v got", tm, ct)
}
}

func TestIssueService_Get_Transitions(t *testing.T) {
setup()
defer teardown()
testMux.HandleFunc("/rest/api/2/issue/10002", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testRequestURL(t, r, "/rest/api/2/issue/10002")

fmt.Fprint(w, `{"expand":"renderedFields,names,schema,transitions,operations,editmeta,changelog,versionedRepresentations","id":"10002","self":"http://www.example.com/jira/api/latest/issue/10002","key":"EX-1","transitions":[{"id":"121","name":"Start","to":{"self":"http://www.example.com/rest/api/2/status/10444","description":"","iconUrl":"http://www.example.com/images/icons/statuses/inprogress.png","name":"In progress","id":"10444","statusCategory":{"self":"http://www.example.com/rest/api/2/statuscategory/4","id":4,"key":"indeterminate","colorName":"yellow","name":"In Progress"}}}]}`)
})

issue, _, _ := testClient.Issue.Get("10002", &GetQueryOptions{Expand: "transitions"})
if issue == nil {
t.Error("Expected issue. Issue is nil")
}

if len(issue.Transitions) != 1 {
t.Errorf("Expected one transition item, %v found", len(issue.Transitions))
}

transition := issue.Transitions[0]

if transition.Name != "Start" {
t.Errorf("Expected 'Start' transition to be available, got %q", transition.Name)
}

if transition.To.Name != "In progress" {
t.Errorf("Expected transition to lead to status 'In progress', got %q", transition.To.Name)
}
}

func TestIssueService_Get_Fields_AffectsVersions(t *testing.T) {
setup()
defer teardown()
Expand Down

0 comments on commit 7530b7c

Please sign in to comment.