diff options
3 files changed, 22 insertions, 0 deletions
diff --git a/app/services/issuable/clone/content_rewriter.rb b/app/services/issuable/clone/content_rewriter.rb index e1e0b75085d..00d7078859d 100644 --- a/app/services/issuable/clone/content_rewriter.rb +++ b/app/services/issuable/clone/content_rewriter.rb @@ -28,6 +28,7 @@ module Issuable new_params = { project: new_entity.project, noteable: new_entity, note: rewrite_content(new_note.note), + note_html: nil, created_at: note.created_at, updated_at: note.updated_at } diff --git a/changelogs/unreleased/57825-moving-an-issue-results-in-broken-image-links-in-comments.yml b/changelogs/unreleased/57825-moving-an-issue-results-in-broken-image-links-in-comments.yml new file mode 100644 index 00000000000..faa1784ea21 --- /dev/null +++ b/changelogs/unreleased/57825-moving-an-issue-results-in-broken-image-links-in-comments.yml @@ -0,0 +1,5 @@ +--- +title: Resolve moving an issue results in broken image links in comments +merge_request: 28654 +author: +type: fixed diff --git a/spec/services/issuable/clone/content_rewriter_spec.rb b/spec/services/issuable/clone/content_rewriter_spec.rb index 4d3cb0bd254..230e1123280 100644 --- a/spec/services/issuable/clone/content_rewriter_spec.rb +++ b/spec/services/issuable/clone/content_rewriter_spec.rb @@ -149,5 +149,21 @@ describe Issuable::Clone::ContentRewriter do expect(new_note.author).to eq(note.author) end end + + context 'notes with upload' do + let(:uploader) { build(:file_uploader, project: project1) } + let(:text) { "Simple text with image: #{uploader.markdown_link} "} + let!(:note) { create(:note, noteable: original_issue, note: text, project: project1) } + + it 'rewrites note content correctly' do + subject.execute + new_note = new_issue.notes.first + + expect(note.note).to match(/Simple text with image: #{FileUploader::MARKDOWN_PATTERN}/) + expect(new_note.note).to match(/Simple text with image: #{FileUploader::MARKDOWN_PATTERN}/) + expect(note.note).not_to eq(new_note.note) + expect(note.note_html).not_to eq(new_note.note_html) + end + end end end |