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

add repository field to issue hook data
This commit is contained in:
Stan Hu 2015-09-17 07:03:47 -07:00
commit b75e4d7149
4 changed files with 29 additions and 0 deletions

View file

@ -52,6 +52,7 @@ v 8.0.0 (unreleased)
- Added service API endpoint to retrieve service parameters (Petheő Bence)
- Add FogBugz project import (Jared Szechy)
- Sort users autocomplete lists by user (Allister Antosik)
- Webhook for issue now contains repository field (Jungkook Park)
v 7.14.3
- No changes

View file

@ -140,6 +140,12 @@ module Issuable
{
object_kind: self.class.name.underscore,
user: user.hook_attrs,
repository: {
name: project.name,
url: project.url_to_repo,
description: project.description,
homepage: project.web_url
},
object_attributes: hook_attrs
}
end

View file

@ -121,6 +121,12 @@ X-Gitlab-Event: Issue Hook
"username": "root",
"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": {
"id": 301,
"title": "New API: create/update/delete file",

View file

@ -2,6 +2,7 @@ require 'spec_helper'
describe Issue, "Issuable" do
let(:issue) { create(:issue) }
let(:user) { create(:user) }
describe "Associations" do
it { is_expected.to belong_to(:project) }
@ -66,4 +67,19 @@ describe Issue, "Issuable" do
expect(issue.new?).to be_falsey
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