Commit 4305d23d authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '13426-bugfix-duplicate-notes-during-design-copy' into 'master'

Fix duplicate design comments being created during issue move

See merge request gitlab-org/gitlab!43958
parents d4db3a95 949ff817
......@@ -246,7 +246,7 @@ module DesignManagement
new_designs = DesignManagement::Design.unscoped.find(design_ids)
# Execute another query to filter only designs with notes
DesignManagement::Design.unscoped.where(id: designs).joins(:notes).find_each(batch_size: 100) do |old_design|
DesignManagement::Design.unscoped.where(id: designs).joins(:notes).distinct.find_each(batch_size: 100) do |old_design|
new_design = new_designs.find { |d| d.filename == old_design.filename }
Notes::CopyService.new(current_user, old_design, new_design).execute
......
......@@ -133,18 +133,26 @@ RSpec.describe DesignManagement::CopyDesignCollection::CopyService, :clean_gitla
end
it 'copies design notes correctly', :aggregate_failures, :sidekiq_inline do
note = create(:diff_note_on_design, noteable: designs.first, project: project)
old_notes = [
create(:diff_note_on_design, note: 'first note', noteable: designs.first, project: project, author: create(:user)),
create(:diff_note_on_design, note: 'second note', noteable: designs.first, project: project, author: create(:user))
]
matchers = old_notes.map do |note|
have_attributes(
note.attributes.slice(
:type,
:author_id,
:note,
:position
)
)
end
expect { subject }.to change { Note.count }.by(1)
expect { subject }.to change { Note.count }.by(2)
new_note = target_issue.designs.first.notes.first
new_notes = target_issue.designs.first.notes.fresh
expect(new_note).to have_attributes(
type: note.type,
author_id: note.author_id,
note: note.note,
position: note.position
)
expect(new_notes).to match_array(matchers)
end
it 'links the LfsObjects' 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