diff --git a/app/services/issues/move_service.rb b/app/services/issues/move_service.rb index 8a39e2d5f4d..d818ed86020 100644 --- a/app/services/issues/move_service.rb +++ b/app/services/issues/move_service.rb @@ -23,8 +23,8 @@ module Issues # Old issue tasks # - close_old_issue add_moved_to_note + close_old_issue # Notifications # @@ -45,20 +45,18 @@ module Issues end def open_new_issue - @issue_new.project = @project_new - @issue_new.save! + @issue_new.update(project: @project_new) end def rewrite_notes @issue_old.notes.find_each do |note| - note_new = note.dup - note_new.project = @project_new - note_new.noteable = @issue_new - note_new.save! + new_note = note.dup + new_note.update(project: @project_new, noteable: @issue_new) end end def close_old_issue + @issue_old.update(state: :closed) end def notify_participants diff --git a/spec/services/issues/move_service_spec.rb b/spec/services/issues/move_service_spec.rb index 6fda8bc6716..3b81cc90c61 100644 --- a/spec/services/issues/move_service_spec.rb +++ b/spec/services/issues/move_service_spec.rb @@ -56,6 +56,15 @@ describe Issues::MoveService, services: true do it 'adds system note to new issue at the end' do expect(new_issue.notes.last.note).to match /^Moved from/ 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 context 'notes exist' do