Commit b75e4d71 authored by Stan Hu's avatar Stan Hu

Merge pull request #9618 from pjknkda/repo-info-to-issue-hook

add repository field to issue hook data
parents 3c2a6174 e4ac2d58
...@@ -52,6 +52,7 @@ v 8.0.0 (unreleased) ...@@ -52,6 +52,7 @@ v 8.0.0 (unreleased)
- Added service API endpoint to retrieve service parameters (Petheő Bence) - Added service API endpoint to retrieve service parameters (Petheő Bence)
- Add FogBugz project import (Jared Szechy) - Add FogBugz project import (Jared Szechy)
- Sort users autocomplete lists by user (Allister Antosik) - Sort users autocomplete lists by user (Allister Antosik)
- Webhook for issue now contains repository field (Jungkook Park)
v 7.14.3 v 7.14.3
- No changes - No changes
......
...@@ -140,6 +140,12 @@ module Issuable ...@@ -140,6 +140,12 @@ module Issuable
{ {
object_kind: self.class.name.underscore, object_kind: self.class.name.underscore,
user: user.hook_attrs, user: user.hook_attrs,
repository: {
name: project.name,
url: project.url_to_repo,
description: project.description,
homepage: project.web_url
},
object_attributes: hook_attrs object_attributes: hook_attrs
} }
end end
......
...@@ -121,6 +121,12 @@ X-Gitlab-Event: Issue Hook ...@@ -121,6 +121,12 @@ X-Gitlab-Event: Issue Hook
"username": "root", "username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon" "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon"
}, },
"repository": {
"name": "Gitlab Test",
"url": "http://example.com/gitlabhq/gitlab-test.git",
"description": "Aut reprehenderit ut est.",
"homepage": "http://example.com/gitlabhq/gitlab-test"
},
"object_attributes": { "object_attributes": {
"id": 301, "id": 301,
"title": "New API: create/update/delete file", "title": "New API: create/update/delete file",
......
...@@ -2,6 +2,7 @@ require 'spec_helper' ...@@ -2,6 +2,7 @@ require 'spec_helper'
describe Issue, "Issuable" do describe Issue, "Issuable" do
let(:issue) { create(:issue) } let(:issue) { create(:issue) }
let(:user) { create(:user) }
describe "Associations" do describe "Associations" do
it { is_expected.to belong_to(:project) } it { is_expected.to belong_to(:project) }
...@@ -66,4 +67,19 @@ describe Issue, "Issuable" do ...@@ -66,4 +67,19 @@ describe Issue, "Issuable" do
expect(issue.new?).to be_falsey expect(issue.new?).to be_falsey
end end
end end
describe "#to_hook_data" do
let(:hook_data) { issue.to_hook_data(user) }
it "returns correct hook data" do
expect(hook_data[:object_kind]).to eq("issue")
expect(hook_data[:user]).to eq(user.hook_attrs)
expect(hook_data[:repository][:name]).to eq(issue.project.name)
expect(hook_data[:repository][:url]).to eq(issue.project.url_to_repo)
expect(hook_data[:repository][:description]).to eq(issue.project.description)
expect(hook_data[:repository][:homepage]).to eq(issue.project.web_url)
expect(hook_data[:object_attributes]).to eq(issue.hook_attrs)
end
end
end end
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