diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /spec/services/draft_notes/publish_service_spec.rb | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'spec/services/draft_notes/publish_service_spec.rb')
-rw-r--r-- | spec/services/draft_notes/publish_service_spec.rb | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/spec/services/draft_notes/publish_service_spec.rb b/spec/services/draft_notes/publish_service_spec.rb index 2e1de367da3..4f761454516 100644 --- a/spec/services/draft_notes/publish_service_spec.rb +++ b/spec/services/draft_notes/publish_service_spec.rb @@ -66,8 +66,8 @@ RSpec.describe DraftNotes::PublishService do let(:commit_id) { nil } before do - create(:draft_note, merge_request: merge_request, author: user, note: 'first note', commit_id: commit_id, position: position) - create(:draft_note, merge_request: merge_request, author: user, note: 'second note', commit_id: commit_id, position: position) + create(:draft_note_on_text_diff, merge_request: merge_request, author: user, note: 'first note', commit_id: commit_id, position: position) + create(:draft_note_on_text_diff, merge_request: merge_request, author: user, note: 'second note', commit_id: commit_id, position: position) end context 'when review fails to create' do @@ -127,6 +127,30 @@ RSpec.describe DraftNotes::PublishService do publish end + context 'capturing diff notes positions' do + before do + # Need to execute this to ensure that we'll be able to test creation of + # DiffNotePosition records as that only happens when the `MergeRequest#merge_ref_head` + # is present. This service creates that for the specified merge request. + MergeRequests::MergeToRefService.new(project: project, current_user: user).execute(merge_request) + end + + it 'creates diff_note_positions for diff notes' do + publish + + notes = merge_request.notes.order(id: :asc) + expect(notes.first.diff_note_positions).to be_any + expect(notes.last.diff_note_positions).to be_any + end + + it 'does not requests a lot from Gitaly', :request_store do + # NOTE: This should be reduced as we work on reducing Gitaly calls. + # Gitaly requests shouldn't go above this threshold as much as possible + # as it may add more to the Gitaly N+1 issue we are experiencing. + expect { publish }.to change { Gitlab::GitalyClient.get_request_count }.by(11) + end + end + context 'commit_id is set' do let(:commit_id) { commit.id } |