From 549821a59f06d8840a6c2d7c500e8d193f6102e1 Mon Sep 17 00:00:00 2001 From: Brett Walker Date: Fri, 25 Jan 2019 09:41:21 -0600 Subject: [PATCH] Add back call to execute_hooks --- app/models/concerns/issuable.rb | 33 +++++++++++++++------------ app/services/issuable_base_service.rb | 6 +---- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index 0d363ec68b7..b1cf03551f6 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -270,26 +270,29 @@ module Issuable 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)] - end + if old_associations + old_labels = old_associations.fetch(:labels, []) + old_assignees = old_associations.fetch(:assignees, []) - 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] + if old_labels != labels + changes[:labels] = [old_labels.map(&:hook_attrs), labels.map(&:hook_attrs)] end - end - if self.respond_to?(:total_time_spent) - old_total_time_spent = old_associations.fetch(:total_time_spent, nil) + 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 - 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 end diff --git a/app/services/issuable_base_service.rb b/app/services/issuable_base_service.rb index dc929aa3b28..cab5dd0e28d 100644 --- a/app/services/issuable_base_service.rb +++ b/app/services/issuable_base_service.rb @@ -237,7 +237,6 @@ class IssuableBaseService < BaseService def update_task(issuable) filter_params(issuable) - # old_associations = associations_before_update(issuable) if issuable.changed? || params.present? issuable.assign_attributes(params.merge(updated_by: current_user)) @@ -252,12 +251,9 @@ class IssuableBaseService < BaseService end handle_task_changes(issuable) - invalidate_cache_counts(issuable, users: issuable.assignees.to_a) - after_update(issuable) - - # execute_hooks(issuable, 'update', old_associations: old_associations) + execute_hooks(issuable, 'update', old_associations: nil) end end