summaryrefslogtreecommitdiff
path: root/spec/services/discussions
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-05-04 10:03:30 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-05-04 10:03:30 +0000
commitd35df0ad158c14cb28f583f4b26c4196ef23a3f7 (patch)
tree5a1992758772519104eacb5de2c231721876541c /spec/services/discussions
parent3c51da6f5782e53123a7ed5af98ba0828cbfa49f (diff)
downloadgitlab-ce-d35df0ad158c14cb28f583f4b26c4196ef23a3f7.tar.gz
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'spec/services/discussions')
-rw-r--r--spec/services/discussions/capture_diff_note_position_service_spec.rb23
1 files changed, 19 insertions, 4 deletions
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 fced2eb7fce..bc71e170e92 100644
--- a/spec/services/discussions/capture_diff_note_position_service_spec.rb
+++ b/spec/services/discussions/capture_diff_note_position_service_spec.rb
@@ -3,10 +3,11 @@
require 'spec_helper'
describe Discussions::CaptureDiffNotePositionService do
+ subject { described_class.new(note.noteable, paths) }
+
context 'image note on diff' do
let!(:note) { create(:image_diff_note_on_merge_request) }
-
- subject { described_class.new(note.noteable, ['files/images/any_image.png']) }
+ let(:paths) { ['files/images/any_image.png'] }
it 'is note affected by the service' do
expect(Gitlab::Diff::PositionTracer).not_to receive(:new)
@@ -18,8 +19,7 @@ describe Discussions::CaptureDiffNotePositionService do
context 'when empty paths are passed as a param' do
let!(:note) { create(:diff_note_on_merge_request) }
-
- subject { described_class.new(note.noteable, []) }
+ let(:paths) { [] }
it 'does not calculate positons' do
expect(Gitlab::Diff::PositionTracer).not_to receive(:new)
@@ -28,4 +28,19 @@ describe Discussions::CaptureDiffNotePositionService do
expect(note.diff_note_positions).to be_empty
end
end
+
+ context 'when position tracer returned nil position' do
+ let!(:note) { create(:diff_note_on_merge_request) }
+ let(:paths) { ['files/any_file.txt'] }
+
+ it 'does not create diff note position' 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 })
+ end
+
+ expect(subject.execute(note.discussion)).to eq(nil)
+ expect(note.diff_note_positions).to be_empty
+ end
+ end
end