diff options
author | Ryan Scott <ryan@ryan-scott.me> | 2017-04-05 11:31:48 +0900 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2017-07-20 15:33:24 +0100 |
commit | 7e3d34595c3e090fe505b4fbd49cde2a303b1b6f (patch) | |
tree | 17a81203a5e9b224c4974a991c5fce81b44953b4 /app | |
parent | 01c9488f4a559063eba77074ba2d369de87b8018 (diff) | |
download | gitlab-ce-7e3d34595c3e090fe505b4fbd49cde2a303b1b6f.tar.gz |
Changes based on MR feedback.
Marking an issue as a duplicate will now also add an upvote on behalf of the author on the original issue.
Diffstat (limited to 'app')
-rw-r--r-- | app/models/system_note_metadata.rb | 5 | ||||
-rw-r--r-- | app/services/issuable_base_service.rb | 20 | ||||
-rw-r--r-- | app/services/system_note_service.rb | 8 |
3 files changed, 17 insertions, 16 deletions
diff --git a/app/models/system_note_metadata.rb b/app/models/system_note_metadata.rb index 1ffdd285b91..0b33e45473b 100644 --- a/app/models/system_note_metadata.rb +++ b/app/models/system_note_metadata.rb @@ -1,8 +1,9 @@ class SystemNoteMetadata < ActiveRecord::Base ICON_TYPES = %w[ commit description merge confidential visible label assignee cross_reference - title time_tracking branch milestone discussion task moved opened closed merged - outdated duplicate + title time_tracking branch milestone discussion task moved + opened closed merged duplicate + outdated ].freeze validates :note, presence: true diff --git a/app/services/issuable_base_service.rb b/app/services/issuable_base_service.rb index c7e646222bb..f57fbaca836 100644 --- a/app/services/issuable_base_service.rb +++ b/app/services/issuable_base_service.rb @@ -50,10 +50,6 @@ class IssuableBaseService < BaseService SystemNoteService.mark_duplicate_issue(issuable, issuable.project, current_user, original_issue) end - def create_cross_reference_note(noteable, mentioner) - SystemNoteService.cross_reference(noteable, mentioner, current_user) - end - def filter_params(issuable) ability_name = :"admin_#{issuable.to_ability_name}" @@ -303,14 +299,18 @@ class IssuableBaseService < BaseService def change_issue_duplicate(issuable) original_issue_id = params.delete(:original_issue_id) - return if original_issue_id.nil? + return unless original_issue_id - original_issue = IssuesFinder.new(current_user).find(original_issue_id) - if original_issue.present? - create_issue_duplicate_note(issuable, original_issue) - close_service.new(project, current_user, {}).execute(issuable) - create_cross_reference_note(original_issue, issuable) + begin + original_issue = IssuesFinder.new(current_user).find(original_issue_id) + rescue ActiveRecord::RecordNotFound + return end + + note = create_issue_duplicate_note(issuable, original_issue) + note.create_cross_references! + close_service.new(project, current_user, {}).execute(issuable) + original_issue.create_award_emoji(AwardEmoji::UPVOTE_NAME, issuable.author) end def toggle_award(issuable) diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb index 2e5e904c43d..ed079f0e495 100644 --- a/app/services/system_note_service.rb +++ b/app/services/system_note_service.rb @@ -552,11 +552,11 @@ module SystemNoteService create_note(NoteSummary.new(noteable, project, author, body, action: 'moved')) end - # Called when a Notable has been marked as a duplicate of another Issue + # Called when a Noteable has been marked as a duplicate of another Issue # - # noteable - Noteable object - # project - Project owning noteable - # author - User performing the change + # noteable - Noteable object + # project - Project owning noteable + # author - User performing the change # original_issue - Issue that this is a duplicate of # # Example Note text: |