Consolidate add/remove issuable resource links in issuable_resource_links_service.rb
The following discussion from !122263 (merged) should be addressed:
-
@ck3g started a discussion: This change also shows that these two functions are almost identical. The only difference between them is "added" vs "removed" words. That's probably a good opportunity to extract a new method.
For example:
def issuable_resource_link_added(resource_link) issuable_resource_link(resource_link, "added") end def issuable_resource_link_removed(resource_link) issuable_resource_link(resource_link, "removed") end private def issuable_resource_link(resource_link, event) link_type = resource_link.general? ? 'resource' : resource_link.link_type.capitalize body = format(_("#{event} a %{link_type} link"), link_type: link_type) create_note(NoteSummary.new(noteable, project, author, body, action: 'relate')) end
I will create a follow-up to improve it.
Implementation Guide
- Apply refactoring suggestion from example above after !122263 (merged) is merged
Edited by Vitali Tatarintev