Commit 17b10338 authored by Douwe Maan's avatar Douwe Maan

Merge branch '30299-fix-polling-for-transformed-notes' into 'master'

Fix polling for transformed individual notes

See merge request gitlab-org/gitlab-ce!25084
parents a77a1e1b a7b1a4ef
......@@ -17,8 +17,6 @@ class Discussion
:for_commit?,
:for_merge_request?,
:save,
to: :first_note
def project_id
......
......@@ -17,8 +17,12 @@ class IndividualNoteDiscussion < Discussion
noteable.supports_replying_to_individual_notes? && Feature.enabled?(:reply_to_individual_notes)
end
def convert_to_discussion!
first_note.becomes!(Discussion.note_class).to_discussion
def convert_to_discussion!(save: false)
first_note.becomes!(Discussion.note_class).to_discussion.tap do
# Save needs to be called on first_note instead of the transformed note
# because of https://gitlab.com/gitlab-org/gitlab-ce/issues/57324
first_note.save if save
end
end
def reply_attributes
......
......@@ -35,7 +35,7 @@ module Notes
if !only_commands && note.save
if note.part_of_discussion? && note.discussion.can_convert_to_discussion?
note.discussion.convert_to_discussion!.save(touch: false)
note.discussion.convert_to_discussion!(save: true)
end
todo_service.new_note(note, current_user)
......
......@@ -311,7 +311,14 @@ describe Notes::CreateService do
end
it 'converts existing note to DiscussionNote' do
expect { subject }.to change { existing_note.reload.type }.from(nil).to('DiscussionNote')
expect do
existing_note
Timecop.freeze(Time.now + 1.minute) { subject }
existing_note.reload
end.to change { existing_note.type }.from(nil).to('DiscussionNote')
.and change { existing_note.updated_at }
end
end
end
......
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