diff options
| author | Douwe Maan <douwe@gitlab.com> | 2017-11-28 08:25:18 +0000 |
|---|---|---|
| committer | Douwe Maan <douwe@gitlab.com> | 2017-11-28 08:25:18 +0000 |
| commit | 74b503639441613799e46965d4b0c83bcd6419ba (patch) | |
| tree | c0806608c4fce286a8fb519e9246f67bab998098 /app/models/concerns | |
| parent | 25a3a1838ab3224be0b6c658ea16fd1b37135372 (diff) | |
| parent | ba62143ac34de6cf96da4a19b498b220f7e5154b (diff) | |
| download | gitlab-ce-74b503639441613799e46965d4b0c83bcd6419ba.tar.gz | |
Merge branch '40226-refactor-the-issuable-s-webhooks-data-architecture' into 'master'
Refactor the way we pass `old associations` to issuable's update services
Closes #40226
See merge request gitlab-org/gitlab-ce!15542
Diffstat (limited to 'app/models/concerns')
| -rw-r--r-- | app/models/concerns/issuable.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index e607707475f..27cd3118f81 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -255,8 +255,10 @@ module Issuable participants(user).include?(user) end - def to_hook_data(user, old_labels: [], old_assignees: [], old_total_time_spent: nil) + def to_hook_data(user, old_associations: {}) changes = previous_changes + old_labels = old_associations.fetch(:labels, []) + old_assignees = old_associations.fetch(:assignees, []) if old_labels != labels changes[:labels] = [old_labels.map(&:hook_attrs), labels.map(&:hook_attrs)] @@ -270,8 +272,12 @@ module Issuable end end - if old_total_time_spent != total_time_spent - changes[:total_time_spent] = [old_total_time_spent, total_time_spent] + if self.respond_to?(:total_time_spent) + old_total_time_spent = old_associations.fetch(:total_time_spent, nil) + + if old_total_time_spent != total_time_spent + changes[:total_time_spent] = [old_total_time_spent, total_time_spent] + end end Gitlab::HookData::IssuableBuilder.new(self).build(user: user, changes: changes) |
