summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Daams <b.daams@science.ru.nl>2015-10-18 00:11:36 +0200
committerRémy Coutable <remy@rymai.me>2016-02-10 09:40:00 +0100
commitd146d9fd8345afbeb12c2f4184d62213023bc98c (patch)
treed0eb7e32443d4f9c6218c6b04b7d0523f64dca76
parent93d62bb8afb54f5ad134bdcdc2a39e08d7e7c993 (diff)
downloadgitlab-ce-brammeleman/3047-add-assignee-data-to-isuable-hook-data.tar.gz
Add assignee data to Issuables' hook_databrammeleman/3047-add-assignee-data-to-isuable-hook-data
-rw-r--r--CHANGELOG1
-rw-r--r--app/models/concerns/issuable.rb5
-rw-r--r--doc/web_hooks/web_hooks.md26
-rw-r--r--spec/models/concerns/issuable_spec.rb10
4 files changed, 35 insertions, 7 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 800f9c7918f..9801766c669 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -386,6 +386,7 @@ v 8.1.0
- Improved performance of the trending projects page
- Remove CI migration task
- Improved performance of finding projects by their namespace
+ - Add assignee data to Issuables' hook_data (Bram Daams)
- Fix bug where transferring a project would result in stale commit links (Stan Hu)
- Fix build trace updating
- Include full path of source and target branch names in New Merge Request page (Stan Hu)
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb
index 04650a9e67a..cf6aa592e2a 100644
--- a/app/models/concerns/issuable.rb
+++ b/app/models/concerns/issuable.rb
@@ -126,7 +126,7 @@ module Issuable
end
def to_hook_data(user)
- {
+ hook_data = {
object_kind: self.class.name.underscore,
user: user.hook_attrs,
repository: {
@@ -137,6 +137,9 @@ module Issuable
},
object_attributes: hook_attrs
}
+ hook_data.merge!(assignee: assignee.hook_attrs) if assignee
+
+ hook_data
end
def label_names
diff --git a/doc/web_hooks/web_hooks.md b/doc/web_hooks/web_hooks.md
index c29037e89c2..c556597225c 100644
--- a/doc/web_hooks/web_hooks.md
+++ b/doc/web_hooks/web_hooks.md
@@ -8,8 +8,8 @@ Web hooks can be used to update an external issue tracker, trigger CI builds, up
## SSL Verification
-By default, the SSL certificate of the webhook endpoint is verified based on
-an internal list of Certificate Authorities,
+By default, the SSL certificate of the webhook endpoint is verified based on
+an internal list of Certificate Authorities,
which means the certificate cannot be self-signed.
You can turn this off in the web hook settings in your GitLab projects.
@@ -76,7 +76,6 @@ X-Gitlab-Event: Push Hook
}
],
"total_commits_count": 4
-
}
```
@@ -158,6 +157,11 @@ X-Gitlab-Event: Issue Hook
"iid": 23,
"url": "http://example.com/diaspora/issues/23",
"action": "open"
+ },
+ "assignee": {
+ "name": "User1",
+ "username": "user1",
+ "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon"
}
}
```
@@ -322,7 +326,12 @@ X-Gitlab-Event: Note Hook
"email": "john@example.com"
}
},
- "work_in_progress": false
+ "work_in_progress": false,
+ "assignee": {
+ "name": "User1",
+ "username": "user1",
+ "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon"
+ }
}
}
```
@@ -397,7 +406,7 @@ X-Gitlab-Event: Note Hook
**Request body:**
-```
+```json
{
"object_kind": "note",
"user": {
@@ -510,7 +519,12 @@ X-Gitlab-Event: Merge Request Hook
},
"work_in_progress": false,
"url": "http://example.com/diaspora/merge_requests/1",
- "action": "open"
+ "action": "open",
+ "assignee": {
+ "name": "User1",
+ "username": "user1",
+ "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon"
+ }
}
}
```
diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb
index 021d62cdf0c..8f09ff03a78 100644
--- a/spec/models/concerns/issuable_spec.rb
+++ b/spec/models/concerns/issuable_spec.rb
@@ -79,6 +79,16 @@ describe Issue, "Issuable" do
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)
+ expect(hook_data).to_not have_key(:assignee)
+ end
+
+ context "issue is assigned" do
+ before { issue.update_attribute(:assignee, user) }
+
+ it "returns correct hook data" do
+ expect(hook_data[:object_attributes]['assignee_id']).to eq(user.id)
+ expect(hook_data[:assignee]).to eq(user.hook_attrs)
+ end
end
end