Skip to content
Snippets Groups Projects
Commit 69b89d4e authored by Grzegorz Bizon's avatar Grzegorz Bizon
Browse files

Add new system note used when issue has been moved

parent b53d9f8a
No related branches found
No related tags found
1 merge request!2831Ability to move issue to another project
Loading
@@ -36,6 +36,7 @@ module Issues
Loading
@@ -36,6 +36,7 @@ module Issues
end end
   
def add_note_moved_to def add_note_moved_to
SystemNoteService.issue_moved_to_another_project(@issue_old, @project, @project_new, @current_user)
end end
end end
end end
Loading
@@ -387,4 +387,21 @@ class SystemNoteService
Loading
@@ -387,4 +387,21 @@ class SystemNoteService
body = "Marked the task **#{new_task.source}** as #{status_label}" body = "Marked the task **#{new_task.source}** as #{status_label}"
create_note(noteable: noteable, project: project, author: author, note: body) create_note(noteable: noteable, project: project, author: author, note: body)
end end
# Called when issue has been moved to another project
#
# issue - Issue that has been moved to another project
# project_from - Source project of the issue
# project_to - Destination project for the issue
# author - User performing the move
#
# Example Note text:
#
# "This issue has been moved to SomeNamespace / SomeProject"
#
# Returns the created Note object
def self.issue_moved_to_another_project(issue, project_from, project_to, author)
body = "This issue has been moved to #{project_to.to_reference} by #{author.to_reference}"
create_note(noteable: issue, project: project_from, author: author, note: body)
end
end end
Loading
@@ -18,5 +18,9 @@ describe Issues::MoveService, services: true do
Loading
@@ -18,5 +18,9 @@ describe Issues::MoveService, services: true do
it 'should create a new issue in a new project' do it 'should create a new issue in a new project' do
expect(new_issue.project).to eq new_project expect(new_issue.project).to eq new_project
end end
it 'should add system note to old issue' do
expect(issue.notes.last.note).to match /This issue has been moved to/
end
end end
end end
Loading
@@ -441,6 +441,26 @@ describe SystemNoteService, services: true do
Loading
@@ -441,6 +441,26 @@ describe SystemNoteService, services: true do
end end
end end
   
describe '.issue_moved_to_another_project' do
subject do
described_class.issue_moved_to_another_project(noteable, project, new_project, author)
end
let(:new_project) { create(:project) }
it 'should notify about issue being moved' do
expect(subject.note).to match /This issue has been moved to/
end
it 'should mention destination project' do
expect(subject.note).to include new_project.to_reference
end
it 'should mention author of that change' do
expect(subject.note).to include author.to_reference
end
end
include JiraServiceHelper include JiraServiceHelper
   
describe 'JIRA integration' do describe 'JIRA integration' do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment