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

fix: regression introduced by new OriginalEstimate attribute #767

Merged
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
11 changes: 7 additions & 4 deletions pkg/jira/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,6 @@ func (*Client) getRequestData(req *CreateRequest) *createRequest {
Summary: req.Summary,
Labels: req.Labels,
epicField: req.EpicField,
TimeTracking: struct {
OriginalEstimate string `json:"originalEstimate,omitempty"`
}{OriginalEstimate: req.OriginalEstimate},
}

switch v := req.Body.(type) {
Expand Down Expand Up @@ -219,6 +216,12 @@ func (*Client) getRequestData(req *CreateRequest) *createRequest {
}
data.Fields.M.AffectsVersions = versions
}
if req.OriginalEstimate != "" {
data.Fields.M.TimeTracking = &struct {
OriginalEstimate string `json:"originalEstimate,omitempty"`
}{OriginalEstimate: req.OriginalEstimate}
}

constructCustomFields(req.CustomFields, req.configuredCustomFields, &data)

return &data
Expand Down Expand Up @@ -307,7 +310,7 @@ type createFields struct {
AffectsVersions []struct {
Name string `json:"name,omitempty"`
} `json:"versions,omitempty"`
TimeTracking struct {
TimeTracking *struct {
OriginalEstimate string `json:"originalEstimate,omitempty"`
} `json:"timetracking,omitempty"`
epicField string
Expand Down
6 changes: 3 additions & 3 deletions pkg/jira/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func TestCreate(t *testing.T) {

func TestCreateSubtask(t *testing.T) {
expectedBody := `{"update":{},"fields":{"project":{"key":"TEST"},"issuetype":{"name":"Sub-task"},` +
`"parent":{"key":"TEST-123"},"summary":"Test sub-task","description":"Test description","timetracking":{}}}`
`"parent":{"key":"TEST-123"},"summary":"Test sub-task","description":"Test description"}}`
testServer := createTestServer{code: 201}
server := testServer.serve(t, expectedBody)
defer server.Close()
Expand Down Expand Up @@ -116,7 +116,7 @@ func TestCreateSubtask(t *testing.T) {

func TestCreateEpic(t *testing.T) {
expectedBody := `{"update":{},"fields":{"customfield_10001":"CLI","description":"Test description","issuetype":{"name":` +
`"Bug"},"priority":{"name":"Normal"},"project":{"key":"TEST"},"summary":"Test bug", "timetracking":{}}}`
`"Bug"},"priority":{"name":"Normal"},"project":{"key":"TEST"},"summary":"Test bug"}}`
testServer := createTestServer{code: 201}
server := testServer.serve(t, expectedBody)
defer server.Close()
Expand Down Expand Up @@ -148,7 +148,7 @@ func TestCreateEpic(t *testing.T) {

func TestCreateEpicNextGen(t *testing.T) {
expectedBody := `{"update":{},"fields":{"description":"Test description","issuetype":{"name":"Bug"},` +
`"parent":{"key":"TEST-123"},"project":{"key":"TEST"},"summary":"Test bug","timetracking":{}}}`
`"parent":{"key":"TEST-123"},"project":{"key":"TEST"},"summary":"Test bug"}}`
testServer := createTestServer{code: 201}
server := testServer.serve(t, expectedBody)
defer server.Close()
Expand Down