Merge branch 'add-labels-to-issue-hook' into 'master'
Added labels to the issue web hook Closes #22313 See merge request !9972
This commit is contained in:
commit
1ac6bb553f
5 changed files with 32 additions and 1 deletions
|
@ -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 = {})
|
||||
|
|
4
changelogs/unreleased/add-labels-to-issue-hook.yml
Normal file
4
changelogs/unreleased/add-labels-to-issue-hook.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue