Commit a2867862 authored by Sean McGivern's avatar Sean McGivern

Merge branch '33064-add-labels-to-note-event-payload' into 'master'

Adding labels to note event payload.

Closes #33064

See merge request gitlab-org/gitlab-ce!29384
parents 02e36679 ed8a00b9
---
title: Add labels to note event payload
merge_request: 29384
author: Sujay Patel
type: added
...@@ -653,7 +653,33 @@ X-Gitlab-Event: Note Hook ...@@ -653,7 +653,33 @@ X-Gitlab-Event: Note Hook
"description": "test", "description": "test",
"milestone_id": null, "milestone_id": null,
"state": "closed", "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 ...@@ -44,6 +44,7 @@ module Gitlab
data[:commit] = build_data_for_commit(project, user, note) data[:commit] = build_data_for_commit(project, user, note)
elsif note.for_issue? elsif note.for_issue?
data[:issue] = note.noteable.hook_attrs data[:issue] = note.noteable.hook_attrs
data[:issue][:labels] = note.noteable.labels(&:hook_attrs)
elsif note.for_merge_request? elsif note.for_merge_request?
data[:merge_request] = note.noteable.hook_attrs data[:merge_request] = note.noteable.hook_attrs
elsif note.for_snippet? elsif note.for_snippet?
......
...@@ -44,7 +44,8 @@ module Gitlab ...@@ -44,7 +44,8 @@ module Gitlab
human_total_time_spent: issue.human_total_time_spent, human_total_time_spent: issue.human_total_time_spent,
human_time_estimate: issue.human_time_estimate, human_time_estimate: issue.human_time_estimate,
assignee_ids: issue.assignee_ids, 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) issue.attributes.with_indifferent_access.slice(*self.class.safe_hook_attributes)
......
...@@ -53,6 +53,8 @@ describe Gitlab::DataBuilder::Note do ...@@ -53,6 +53,8 @@ describe Gitlab::DataBuilder::Note do
.to eq(issue.reload.hook_attrs.except('updated_at')) .to eq(issue.reload.hook_attrs.except('updated_at'))
expect(data[:issue]['updated_at']) expect(data[:issue]['updated_at'])
.to be >= issue.hook_attrs['updated_at'] .to be >= issue.hook_attrs['updated_at']
expect(data[:issue]['labels'])
.to eq(issue.hook_attrs['labels'])
end end
context 'with confidential issue' do 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