diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2019-07-12 11:26:59 +0000 |
---|---|---|
committer | Jan Provaznik <jprovaznik@gitlab.com> | 2019-07-12 11:26:59 +0000 |
commit | d1a661dd9c2b2644cd6c292d30a3e8e6a8cc31b3 (patch) | |
tree | 62ecebb260f3bc12b4cfe5d0d1783cb2f307d22b | |
parent | a0c86c1fd47177c7c8924967d710545d5f5c57d1 (diff) | |
parent | 435be1442f03372f42c368efdd8bf941a577e7b6 (diff) | |
download | gitlab-ce-d1a661dd9c2b2644cd6c292d30a3e8e6a8cc31b3.tar.gz |
Merge branch '11445-fix-promoted-epic-inherited-discussions-ce' into 'master'
Port EE: Fix reply to discussion on promoted epic
See merge request gitlab-org/gitlab-ce!30411
-rw-r--r-- | app/services/issuable/clone/content_rewriter.rb | 6 | ||||
-rw-r--r-- | spec/services/issuable/clone/content_rewriter_spec.rb | 13 |
2 files changed, 18 insertions, 1 deletions
diff --git a/app/services/issuable/clone/content_rewriter.rb b/app/services/issuable/clone/content_rewriter.rb index 00d7078859d..f75b51c4be3 100644 --- a/app/services/issuable/clone/content_rewriter.rb +++ b/app/services/issuable/clone/content_rewriter.rb @@ -23,10 +23,14 @@ module Issuable end def rewrite_notes + new_discussion_ids = {} original_entity.notes_with_associations.find_each do |note| new_note = note.dup + new_discussion_ids[note.discussion_id] ||= Discussion.discussion_id(new_note) new_params = { - project: new_entity.project, noteable: new_entity, + project: new_entity.project, + noteable: new_entity, + discussion_id: new_discussion_ids[note.discussion_id], note: rewrite_content(new_note.note), note_html: nil, created_at: note.created_at, diff --git a/spec/services/issuable/clone/content_rewriter_spec.rb b/spec/services/issuable/clone/content_rewriter_spec.rb index 230e1123280..3479c20862a 100644 --- a/spec/services/issuable/clone/content_rewriter_spec.rb +++ b/spec/services/issuable/clone/content_rewriter_spec.rb @@ -165,5 +165,18 @@ describe Issuable::Clone::ContentRewriter do expect(note.note_html).not_to eq(new_note.note_html) end end + + context "discussion notes" do + let(:note) { create(:note, noteable: original_issue, note: "sample note", project: project1) } + let!(:discussion) { create(:discussion_note_on_issue, in_reply_to: note, note: "reply to sample note") } + + it 'rewrites discussion correctly' do + subject.execute + + expect(new_issue.notes.count).to eq(original_issue.notes.count) + expect(new_issue.notes.where(discussion_id: discussion.discussion_id).count).to eq(0) + expect(original_issue.notes.where(discussion_id: discussion.discussion_id).count).to eq(1) + end + end end end |