Added labels to the issue web hook

上级 4a81867d
...@@ -261,6 +261,7 @@ module Issuable ...@@ -261,6 +261,7 @@ module Issuable
user: user.hook_attrs, user: user.hook_attrs,
project: project.hook_attrs, project: project.hook_attrs,
object_attributes: hook_attrs, object_attributes: hook_attrs,
labels: labels.map(&:hook_attrs),
# DEPRECATED # DEPRECATED
repository: project.hook_attrs.slice(:name, :url, :description, :homepage) repository: project.hook_attrs.slice(:name, :url, :description, :homepage)
} }
......
...@@ -169,6 +169,10 @@ class Label < ActiveRecord::Base ...@@ -169,6 +169,10 @@ class Label < ActiveRecord::Base
end end
end end
def hook_attrs
attributes
end
private private
def issues_count(user, params = {}) def issues_count(user, params = {})
......
---
title: Added labels array to the issue web hook returned object
merge_request: 9972
author:
...@@ -250,7 +250,19 @@ X-Gitlab-Event: Issue Hook ...@@ -250,7 +250,19 @@ X-Gitlab-Event: Issue Hook
"name": "User1", "name": "User1",
"username": "user1", "username": "user1",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon" "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon"
} },
"labels": [{
"id": 206,
"title": "API",
"color": "#ffffff",
"project_id": 14,
"created_at": "2013-12-03T17:15:43Z",
"updated_at": "2013-12-03T17:15:43Z",
"template": false,
"description": "API related issues",
"type": "ProjectLabel",
"group_id": 41
}]
} }
``` ```
### Comment events ### Comment events
......
...@@ -278,6 +278,16 @@ describe Issue, "Issuable" do ...@@ -278,6 +278,16 @@ describe Issue, "Issuable" do
end end
end end
context 'issue has labels' do
let(:labels) { [create(:label), create(:label)] }
before { issue.update_attribute(:labels, labels)}
it 'includes labels in the hook data' do
expect(data[:labels]).to eq(labels.map(&:hook_attrs))
end
end
include_examples 'project hook data' include_examples 'project hook data'
include_examples 'deprecated repository hook data' include_examples 'deprecated repository hook data'
end end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册