Commit ed8a00b9 authored by Sujay Patel's avatar Sujay Patel Committed by sujay

Adding labels to note event payload.

parent 6aa0df5a
---
title: Add labels to note event payload
merge_request: 29384
author: Sujay Patel
type: added
......@@ -653,7 +653,33 @@ X-Gitlab-Event: Note Hook
"description": "test",
"milestone_id": null,
"state": "closed",
"iid": 17
"iid": 17,
"labels": [
{
"id": 25,
"title": "Afterpod",
"color": "#3e8068",
"project_id": null,
"created_at": "2019-06-05T14:32:20.211Z",
"updated_at": "2019-06-05T14:32:20.211Z",
"template": false,
"description": null,
"type": "GroupLabel",
"group_id": 4
},
{
"id": 86,
"title": "Element",
"color": "#231afe",
"project_id": 4,
"created_at": "2019-06-05T14:32:20.637Z",
"updated_at": "2019-06-05T14:32:20.637Z",
"template": false,
"description": null,
"type": "ProjectLabel",
"group_id": null
}
],
}
}
```
......
......@@ -44,6 +44,7 @@ module Gitlab
data[:commit] = build_data_for_commit(project, user, note)
elsif note.for_issue?
data[:issue] = note.noteable.hook_attrs
data[:issue][:labels] = note.noteable.labels(&:hook_attrs)
elsif note.for_merge_request?
data[:merge_request] = note.noteable.hook_attrs
elsif note.for_snippet?
......
......@@ -44,7 +44,8 @@ module Gitlab
human_total_time_spent: issue.human_total_time_spent,
human_time_estimate: issue.human_time_estimate,
assignee_ids: issue.assignee_ids,
assignee_id: issue.assignee_ids.first # This key is deprecated
assignee_id: issue.assignee_ids.first, # This key is deprecated
labels: issue.labels
}
issue.attributes.with_indifferent_access.slice(*self.class.safe_hook_attributes)
......
......@@ -53,6 +53,8 @@ describe Gitlab::DataBuilder::Note do
.to eq(issue.reload.hook_attrs.except('updated_at'))
expect(data[:issue]['updated_at'])
.to be >= issue.hook_attrs['updated_at']
expect(data[:issue]['labels'])
.to eq(issue.hook_attrs['labels'])
end
context 'with confidential issue' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment