Move common behavior to to IssuableBaseService

parent 372cdf4c
...@@ -71,6 +71,19 @@ class IssuableBaseService < BaseService ...@@ -71,6 +71,19 @@ class IssuableBaseService < BaseService
end end
end end
def have_changes?(issuable, options = {})
valid_attrs = [:title, :description, :assignee_id, :milestone_id, :target_branch]
attrs_changed = valid_attrs.any? do |attr|
issuable.previous_changes.include?(attr.to_s)
end
old_labels = options[:old_labels]
labels_changed = old_labels && issuable.labels != old_labels
attrs_changed || labels_changed
end
def handle_common_system_notes(issuable, options = {}) def handle_common_system_notes(issuable, options = {})
if issuable.previous_changes.include?('title') if issuable.previous_changes.include?('title')
create_title_change_note(issuable, issuable.previous_changes['title'].first) create_title_change_note(issuable, issuable.previous_changes['title'].first)
......
...@@ -27,22 +27,5 @@ module Issues ...@@ -27,22 +27,5 @@ module Issues
def close_service def close_service
Issues::CloseService Issues::CloseService
end end
private
def have_changes?(issue, options = {})
valid_attrs = [:title, :description, :assignee_id, :milestone_id]
attrs_changed = valid_attrs.any? do |attr|
issue.previous_changes.include?(attr.to_s)
end
old_labels = options[:old_labels]
labels_changed = old_labels && issue.labels != old_labels
if attrs_changed || labels_changed
task_service.mark_as_done(issue, current_user)
end
end
end end
end end
...@@ -48,22 +48,5 @@ module MergeRequests ...@@ -48,22 +48,5 @@ module MergeRequests
def close_service def close_service
MergeRequests::CloseService MergeRequests::CloseService
end end
private
def have_changes?(merge_request, options = {})
valid_attrs = [:title, :description, :assignee_id, :milestone_id, :target_branch]
attrs_changed = valid_attrs.any? do |attr|
merge_request.previous_changes.include?(attr.to_s)
end
old_labels = options[:old_labels]
labels_changed = old_labels && merge_request.labels != old_labels
if attrs_changed || labels_changed
task_service.mark_as_done(merge_request, current_user)
end
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment