summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-24 20:10:56 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-24 20:10:56 +0000
commitb542c8ae344bbdd763d10afdcd6921fd268b7832 (patch)
tree3201c706f5495eb5feca0aaf49d28a00130b53a2
parent9119206b6e8aefc4ae25a0d366e7a9788c0a2abd (diff)
downloadgitlab-ce-b542c8ae344bbdd763d10afdcd6921fd268b7832.tar.gz
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
-rw-r--r--app/services/discussions/capture_diff_note_position_service.rb5
-rw-r--r--changelogs/unreleased/236190-bugfix-issue-promote-with-attachments.yml5
-rw-r--r--changelogs/unreleased/id-fix-nil-line-codes-for-diff-positions.yml5
-rw-r--r--spec/services/discussions/capture_diff_note_position_service_spec.rb25
4 files changed, 34 insertions, 6 deletions
diff --git a/app/services/discussions/capture_diff_note_position_service.rb b/app/services/discussions/capture_diff_note_position_service.rb
index 4e8fd90a2e7..87aa27e455f 100644
--- a/app/services/discussions/capture_diff_note_position_service.rb
+++ b/app/services/discussions/capture_diff_note_position_service.rb
@@ -19,13 +19,16 @@ module Discussions
position = result[:position]
return unless position
+ line_code = position.line_code(project.repository)
+ return unless line_code
+
# Currently position data is copied across all notes of a discussion
# It makes sense to store a position only for the first note instead
# Within the newly introduced table we can start doing just that
DiffNotePosition.create_or_update_for(discussion.notes.first,
diff_type: :head,
position: position,
- line_code: position.line_code(project.repository))
+ line_code: line_code)
end
private
diff --git a/changelogs/unreleased/236190-bugfix-issue-promote-with-attachments.yml b/changelogs/unreleased/236190-bugfix-issue-promote-with-attachments.yml
new file mode 100644
index 00000000000..4102c0649d3
--- /dev/null
+++ b/changelogs/unreleased/236190-bugfix-issue-promote-with-attachments.yml
@@ -0,0 +1,5 @@
+---
+title: Fix bug when promoting an Issue with attachments to an Epic
+merge_request: 39654
+author:
+type: fixed
diff --git a/changelogs/unreleased/id-fix-nil-line-codes-for-diff-positions.yml b/changelogs/unreleased/id-fix-nil-line-codes-for-diff-positions.yml
new file mode 100644
index 00000000000..1d7b495e8f0
--- /dev/null
+++ b/changelogs/unreleased/id-fix-nil-line-codes-for-diff-positions.yml
@@ -0,0 +1,5 @@
+---
+title: Avoid creating diff position when line-code is nil
+merge_request: 40089
+author:
+type: fixed
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