From b542c8ae344bbdd763d10afdcd6921fd268b7832 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Mon, 24 Aug 2020 20:10:56 +0000 Subject: Add latest changes from gitlab-org/gitlab@13-3-stable-ee --- .../capture_diff_note_position_service_spec.rb | 25 +++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'spec/services') diff --git a/spec/services/discussions/capture_diff_note_position_service_spec.rb b/spec/services/discussions/capture_diff_note_position_service_spec.rb index 0913ddd8ef2..11614ccfd55 100644 --- a/spec/services/discussions/capture_diff_note_position_service_spec.rb +++ b/spec/services/discussions/capture_diff_note_position_service_spec.rb @@ -29,18 +29,33 @@ RSpec.describe Discussions::CaptureDiffNotePositionService do end end - context 'when position tracer returned nil position' do + context 'when position tracer returned position' do let!(:note) { create(:diff_note_on_merge_request) } let(:paths) { ['files/any_file.txt'] } - it 'does not create diff note position' do + before do expect(note.noteable).to receive(:merge_ref_head).and_return(double.as_null_object) expect_next_instance_of(Gitlab::Diff::PositionTracer) do |tracer| - expect(tracer).to receive(:trace).and_return({ position: nil }) + expect(tracer).to receive(:trace).and_return({ position: position }) end + end - expect(subject.execute(note.discussion)).to eq(nil) - expect(note.diff_note_positions).to be_empty + context 'which is nil' do + let(:position) { nil } + + it 'does not create diff note position' do + expect(subject.execute(note.discussion)).to eq(nil) + expect(note.diff_note_positions).to be_empty + end + end + + context 'which does not have a corresponding line' do + let(:position) { double(line_code: nil) } + + it 'does not create diff note position' do + expect(subject.execute(note.discussion)).to eq(nil) + expect(note.diff_note_positions).to be_empty + end end end end -- cgit v1.2.1