Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2024-05-13 00:17:36 +00:00
parent ece97cdf52
commit 5d89d483f8
5 changed files with 14 additions and 11 deletions

View File

@ -1 +1 @@
7aa06a578d76bdc294ee8e9acb4f063e7d9f1d5f
1f796d76e13237a957abccde4a07fb5b2d177241

View File

@ -5,7 +5,7 @@ class DraftNote < ApplicationRecord
include Sortable
include ShaAttribute
PUBLISH_ATTRS = %i[noteable_id noteable_type type note internal].freeze
PUBLISH_ATTRS = %i[noteable type note internal].freeze
DIFF_ATTRS = %i[position original_position change_position commit_id].freeze
sha_attribute :commit_id

View File

@ -20,7 +20,11 @@ module Notes
discussion = discussion.convert_to_discussion! if discussion.can_convert_to_discussion?
params.merge!(discussion.reply_attributes)
reply_attributes = discussion.reply_attributes
# NOTE: Avoid overriding noteable if it already exists so that we don't have to reload noteable.
reply_attributes = reply_attributes.except(:noteable_id, :noteable_type) if params[:noteable]
params.merge!(reply_attributes)
end
# The `confidential` param for notes is deprecated with 15.3

View File

@ -59,7 +59,7 @@ module QA
image: #{ci_test_image}
stage: test
script:
- 'id=$(curl --header "PRIVATE-TOKEN: #{masked_token}" "https://${CI_SERVER_HOST}/api/v4/projects/#{project.id}/registry/repositories" | jq ".[0].id")'
- 'id=$(curl --header "PRIVATE-TOKEN: #{masked_token}" "https://${CI_SERVER_HOST}/api/v4/projects/#{project.id}/registry/repositories" | tac | jq ".[0].id")'
- echo $id
- 'tag_count=$(curl --header "PRIVATE-TOKEN: #{masked_token}" "https://${CI_SERVER_HOST}/api/v4/projects/#{project.id}/registry/repositories/$id/tags" | jq ". | length")'
- if [ $tag_count -ne 1 ]; then exit 1; fi;

View File

@ -224,19 +224,17 @@ RSpec.describe DraftNotes::PublishService, feature_category: :code_review_workfl
end
end
context 'with many draft notes', :use_sql_query_cache do
context 'with many draft notes', :use_sql_query_cache, :request_store do
let(:merge_request) { create(:merge_request) }
it 'reduce N+1 queries' do
create(:draft_note_on_text_diff, merge_request: merge_request, author: user, note: 'note 1')
create(:draft_note_on_text_diff, merge_request: merge_request, author: user, note: 'note 2')
create(:draft_note_on_text_diff, merge_request: merge_request, author: user, note: 'note 3')
create(:draft_note_on_text_diff, merge_request: merge_request, author: user, note: 'note 4')
create(:draft_note_on_text_diff, merge_request: merge_request, author: user, note: 'note 5')
5.times do
create(:draft_note_on_discussion, merge_request: merge_request, author: user, note: 'some note')
end
recorder = ActiveRecord::QueryRecorder.new(skip_cached: false) { publish }
expect(recorder.count).not_to be > 186
expect(recorder.count).not_to be > 105
end
end
@ -303,6 +301,7 @@ RSpec.describe DraftNotes::PublishService, feature_category: :code_review_workfl
refresh = MergeRequests::RefreshService.new(project: project, current_user: user)
refresh.execute(oldrev, newrev, merge_request.source_branch_ref)
merge_request.reload
expect { publish(draft: draft) }.to change { Suggestion.count }.by(1)
.and change { DiffNote.count }.from(0).to(1)