Skip to content

Commit 7530b7c

Browse files
Korenevskiy Denisghostsquad
Korenevskiy Denis
authored andcommitted
feat: provide access to issue transitions loaded from JIRA API
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
1 parent 1c3507a commit 7530b7c

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

issue.go

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ type Issue struct {
4646
Fields *IssueFields `json:"fields,omitempty" structs:"fields,omitempty"`
4747
RenderedFields *IssueRenderedFields `json:"renderedFields,omitempty" structs:"renderedFields,omitempty"`
4848
Changelog *Changelog `json:"changelog,omitempty" structs:"changelog,omitempty"`
49+
Transitions []Transition `json:"transitions,omitempty" structs:"transitions,omitempty"`
4950
}
5051

5152
// ChangelogItems reflects one single changelog item of a history item

issue_test.go

+31
Original file line numberDiff line numberDiff line change
@@ -1564,6 +1564,37 @@ func TestIssueService_Get_Fields_Changelog(t *testing.T) {
15641564
t.Errorf("Expected CreatedTime func return %v time, %v got", tm, ct)
15651565
}
15661566
}
1567+
1568+
func TestIssueService_Get_Transitions(t *testing.T) {
1569+
setup()
1570+
defer teardown()
1571+
testMux.HandleFunc("/rest/api/2/issue/10002", func(w http.ResponseWriter, r *http.Request) {
1572+
testMethod(t, r, "GET")
1573+
testRequestURL(t, r, "/rest/api/2/issue/10002")
1574+
1575+
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"}}}]}`)
1576+
})
1577+
1578+
issue, _, _ := testClient.Issue.Get("10002", &GetQueryOptions{Expand: "transitions"})
1579+
if issue == nil {
1580+
t.Error("Expected issue. Issue is nil")
1581+
}
1582+
1583+
if len(issue.Transitions) != 1 {
1584+
t.Errorf("Expected one transition item, %v found", len(issue.Transitions))
1585+
}
1586+
1587+
transition := issue.Transitions[0]
1588+
1589+
if transition.Name != "Start" {
1590+
t.Errorf("Expected 'Start' transition to be available, got %q", transition.Name)
1591+
}
1592+
1593+
if transition.To.Name != "In progress" {
1594+
t.Errorf("Expected transition to lead to status 'In progress', got %q", transition.To.Name)
1595+
}
1596+
}
1597+
15671598
func TestIssueService_Get_Fields_AffectsVersions(t *testing.T) {
15681599
setup()
15691600
defer teardown()

0 commit comments

Comments
 (0)