Added labels to the issue web hook

上级 4a81867d
......@@ -261,6 +261,7 @@ module Issuable
user: user.hook_attrs,
project: project.hook_attrs,
object_attributes: hook_attrs,
labels: labels.map(&:hook_attrs),
# DEPRECATED
repository: project.hook_attrs.slice(:name, :url, :description, :homepage)
}
......
......@@ -169,6 +169,10 @@ class Label < ActiveRecord::Base
end
end
def hook_attrs
attributes
end
private
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
"name": "User1",
"username": "user1",
"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
......
......@@ -278,6 +278,16 @@ describe Issue, "Issuable" do
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 'deprecated repository hook data'
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册