summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2015-09-17 07:03:47 -0700
committerStan Hu <stanhu@gmail.com>2015-09-17 07:03:47 -0700
commitb75e4d7149ff40ac4519234b2e351521eb038982 (patch)
treec21547cebb51c9e9d58db0b38c7c550f34bcd141
parent3c2a6174f9052572d6aea1248e9e03752bb48f73 (diff)
parente4ac2d582c729cc22e0da7ab894be04a187eb006 (diff)
downloadgitlab-ce-b75e4d7149ff40ac4519234b2e351521eb038982.tar.gz
Merge pull request #9618 from pjknkda/repo-info-to-issue-hook
add repository field to issue hook data
-rw-r--r--CHANGELOG1
-rw-r--r--app/models/concerns/issuable.rb6
-rw-r--r--doc/web_hooks/web_hooks.md6
-rw-r--r--spec/models/concerns/issuable_spec.rb16
4 files changed, 29 insertions, 0 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 7a7f86bcba8..aab2416a09b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -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
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb
index 40642dc63ba..4db4ffb2e79 100644
--- a/app/models/concerns/issuable.rb
+++ b/app/models/concerns/issuable.rb
@@ -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
diff --git a/doc/web_hooks/web_hooks.md b/doc/web_hooks/web_hooks.md
index 09400d9b163..f4701bb6db2 100644
--- a/doc/web_hooks/web_hooks.md
+++ b/doc/web_hooks/web_hooks.md
@@ -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",
diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb
index b6d80451d2e..8f706f8934b 100644
--- a/spec/models/concerns/issuable_spec.rb
+++ b/spec/models/concerns/issuable_spec.rb
@@ -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