diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-02-24 16:27:06 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-03-17 07:39:15 +0100 |
commit | efd8251751c85285e6519fd3dd756f74579da15b (patch) | |
tree | 5c019d66b47a8e52c039b803bdf5c8c97acc73f9 /app/services | |
parent | c2d4060f26d06d1ce5450345a8be2bbf9186745f (diff) | |
download | gitlab-ce-efd8251751c85285e6519fd3dd756f74579da15b.tar.gz |
Minor refactoring of issue move service and specs
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/issues/move_service.rb | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/app/services/issues/move_service.rb b/app/services/issues/move_service.rb index 782b8b6a430..a404a64cfe9 100644 --- a/app/services/issues/move_service.rb +++ b/app/services/issues/move_service.rb @@ -79,28 +79,30 @@ module Issues SystemNoteService.noteable_moved(:to, @issue_old, @project_old, @issue_new, @current_user) end - def rewrite_references(mentionable) - references = mentionable.all_references - new_content = mentionable_content(mentionable).dup - cross_project_refs = [:issues, :merge_requests, :milestones, - :snippets, :commits, :commit_ranges] - - cross_project_refs.each do |type| - references.public_send(type).each do |mentioned| - new_content.gsub!(mentioned.to_reference, - mentioned.to_reference(@project_new)) + def rewrite_references(noteable) + references = noteable.all_references + new_content = noteable_content(noteable).dup + cross_project_mentionables = [:issues, :merge_requests, :milestones, + :snippets, :commits, :commit_ranges] + + cross_project_mentionables.each do |type| + references.public_send(type).each do |mentionable| + new_content.gsub!(mentionable.to_reference, + mentionable.to_reference(@project_new)) end end new_content end - def mentionable_content(mentionable) - case mentionable - when Issue then mentionable.description - when Note then mentionable.note + def noteable_content(noteable) + case noteable + when Issue + noteable.description + when Note + noteable.note else - raise 'Unexpected mentionable while moving an issue' + raise 'Unexpected noteable while moving an issue' end end end |