summaryrefslogtreecommitdiff
path: root/app/models/concerns/issuable.rb
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-09-19 19:23:15 +0200
committerRémy Coutable <remy@rymai.me>2017-10-09 15:07:10 +0200
commit075d6516047d899746d22b5323d3b74558e200d0 (patch)
treef958ce8b1ab36d898e9d8dc894e0ed63fbcf7ebd /app/models/concerns/issuable.rb
parent67d5ca9f9220e5572f3fa6d0d8290cd7b802f02f (diff)
downloadgitlab-ce-075d6516047d899746d22b5323d3b74558e200d0.tar.gz
Start adding Gitlab::HookData::IssuableBuilder
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'app/models/concerns/issuable.rb')
-rw-r--r--app/models/concerns/issuable.rb27
1 files changed, 10 insertions, 17 deletions
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb
index e8a6c37d0b9..27f4dedffd3 100644
--- a/app/models/concerns/issuable.rb
+++ b/app/models/concerns/issuable.rb
@@ -256,29 +256,22 @@ module Issuable
participants(user).include?(user)
end
- def to_hook_data(user, old_labels: [])
+ def to_hook_data(user, old_labels: [], old_assignees: [])
changes = previous_changes
+
if old_labels != labels
- changes[:labels] = [old_labels.map(&:name), labels.map(&:name)]
+ changes[:labels] = [old_labels.map(&:hook_attrs), labels.map(&:hook_attrs)]
end
- hook_data = {
- object_kind: self.class.name.underscore,
- user: user.hook_attrs,
- project: project.hook_attrs,
- object_attributes: hook_attrs,
- labels: labels.map(&:hook_attrs),
- changes: changes,
- # DEPRECATED
- repository: project.hook_attrs.slice(:name, :url, :description, :homepage)
- }
- if self.is_a?(Issue)
- hook_data[:assignees] = assignees.map(&:hook_attrs) if assignees.any?
- else
- hook_data[:assignee] = assignee.hook_attrs if assignee
+ if old_assignees != assignees
+ if self.is_a?(Issue)
+ changes[:assignees] = [old_assignees.map(&:hook_attrs), assignees.map(&:hook_attrs)]
+ else
+ changes[:assignee] = [old_assignees&.first&.hook_attrs, assignee&.hook_attrs]
+ end
end
- hook_data
+ Gitlab::HookData::IssuableBuilder.new(self).build(user: user, changes: changes)
end
def labels_array