Commit fab69546 authored by Z.J. van de Weg's avatar Z.J. van de Weg

Move awardables too when issue is moved

parent 91a7b933
...@@ -24,6 +24,7 @@ module Issues ...@@ -24,6 +24,7 @@ module Issues
@new_issue = create_new_issue @new_issue = create_new_issue
rewrite_notes rewrite_notes
rewrite_award_emoji
add_note_moved_from add_note_moved_from
# Old issue tasks # Old issue tasks
...@@ -72,6 +73,14 @@ module Issues ...@@ -72,6 +73,14 @@ module Issues
end end
end end
def rewrite_award_emoji
@old_issue.award_emoji.each do |award|
new_award = award.dup
new_award.awardable = @new_issue
new_award.save
end
end
def rewrite_content(content) def rewrite_content(content)
return unless content return unless content
......
...@@ -39,6 +39,7 @@ describe Issues::MoveService, services: true do ...@@ -39,6 +39,7 @@ describe Issues::MoveService, services: true do
let!(:milestone2) do let!(:milestone2) do
create(:milestone, project_id: new_project.id, title: 'v9.0') create(:milestone, project_id: new_project.id, title: 'v9.0')
end end
let!(:award_emoji) { create(:award_emoji, awardable: old_issue) }
let!(:new_issue) { move_service.execute(old_issue, new_project) } let!(:new_issue) { move_service.execute(old_issue, new_project) }
end end
...@@ -115,6 +116,10 @@ describe Issues::MoveService, services: true do ...@@ -115,6 +116,10 @@ describe Issues::MoveService, services: true do
it 'preserves create time' do it 'preserves create time' do
expect(old_issue.created_at).to eq new_issue.created_at expect(old_issue.created_at).to eq new_issue.created_at
end end
it 'moves the award emoji' do
expect(old_issue.award_emoji.first.name).to eq new_issue.reload.award_emoji.first.name
end
end end
context 'issue with notes' do context 'issue with notes' 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