Silently close old issue when it has been moved
This commit is contained in:
parent
8a02449440
commit
5ed8a1e107
2 changed files with 14 additions and 7 deletions
|
@ -23,8 +23,8 @@ module Issues
|
||||||
|
|
||||||
# Old issue tasks
|
# Old issue tasks
|
||||||
#
|
#
|
||||||
close_old_issue
|
|
||||||
add_moved_to_note
|
add_moved_to_note
|
||||||
|
close_old_issue
|
||||||
|
|
||||||
# Notifications
|
# Notifications
|
||||||
#
|
#
|
||||||
|
@ -45,20 +45,18 @@ module Issues
|
||||||
end
|
end
|
||||||
|
|
||||||
def open_new_issue
|
def open_new_issue
|
||||||
@issue_new.project = @project_new
|
@issue_new.update(project: @project_new)
|
||||||
@issue_new.save!
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def rewrite_notes
|
def rewrite_notes
|
||||||
@issue_old.notes.find_each do |note|
|
@issue_old.notes.find_each do |note|
|
||||||
note_new = note.dup
|
new_note = note.dup
|
||||||
note_new.project = @project_new
|
new_note.update(project: @project_new, noteable: @issue_new)
|
||||||
note_new.noteable = @issue_new
|
|
||||||
note_new.save!
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def close_old_issue
|
def close_old_issue
|
||||||
|
@issue_old.update(state: :closed)
|
||||||
end
|
end
|
||||||
|
|
||||||
def notify_participants
|
def notify_participants
|
||||||
|
|
|
@ -56,6 +56,15 @@ describe Issues::MoveService, services: true do
|
||||||
it 'adds system note to new issue at the end' do
|
it 'adds system note to new issue at the end' do
|
||||||
expect(new_issue.notes.last.note).to match /^Moved from/
|
expect(new_issue.notes.last.note).to match /^Moved from/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'closes old issue' do
|
||||||
|
expect(old_issue.closed?).to be true
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'persists changes to old and new issue' do
|
||||||
|
expect(new_issue.changed?).to be false
|
||||||
|
expect(old_issue.changed?).to be false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'notes exist' do
|
context 'notes exist' do
|
||||||
|
|
Loading…
Reference in a new issue