Commit 69b89d4e authored by Grzegorz Bizon's avatar Grzegorz Bizon

Add new system note used when issue has been moved

parent b53d9f8a
......@@ -36,6 +36,7 @@ module Issues
end
def add_note_moved_to
SystemNoteService.issue_moved_to_another_project(@issue_old, @project, @project_new, @current_user)
end
end
end
......@@ -387,4 +387,21 @@ class SystemNoteService
body = "Marked the task **#{new_task.source}** as #{status_label}"
create_note(noteable: noteable, project: project, author: author, note: body)
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
......@@ -18,5 +18,9 @@ describe Issues::MoveService, services: true do
it 'should create a new issue in a new project' do
expect(new_issue.project).to eq new_project
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
......@@ -441,6 +441,26 @@ describe SystemNoteService, services: true do
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
describe 'JIRA integration' do
......
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