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

Fix polling for transformed individual notes

See merge request gitlab-org/gitlab-ce!25084
This commit is contained in:
Douwe Maan 2019-02-13 20:31:25 +00:00
commit 17b1033850
4 changed files with 15 additions and 6 deletions

View file

@ -17,8 +17,6 @@ class Discussion
:for_commit?, :for_commit?,
:for_merge_request?, :for_merge_request?,
:save,
to: :first_note to: :first_note
def project_id def project_id

View file

@ -17,8 +17,12 @@ class IndividualNoteDiscussion < Discussion
noteable.supports_replying_to_individual_notes? && Feature.enabled?(:reply_to_individual_notes) noteable.supports_replying_to_individual_notes? && Feature.enabled?(:reply_to_individual_notes)
end end
def convert_to_discussion! def convert_to_discussion!(save: false)
first_note.becomes!(Discussion.note_class).to_discussion 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 end
def reply_attributes def reply_attributes

View file

@ -35,7 +35,7 @@ module Notes
if !only_commands && note.save if !only_commands && note.save
if note.part_of_discussion? && note.discussion.can_convert_to_discussion? 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 end
todo_service.new_note(note, current_user) todo_service.new_note(note, current_user)

View file

@ -311,7 +311,14 @@ describe Notes::CreateService do
end end
it 'converts existing note to DiscussionNote' do 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 end
end end