Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-15 15:09:18 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-15 15:09:18 +0300
commitb7c735c8ac11b8182807070fc6f84f2606e15427 (patch)
treee74b4d25abb8bbf23546f001dd94515e2840a3a3 /app/models/diff_note_position.rb
parent221b529789f4090341a825695aeb49b8df6dd11d (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/diff_note_position.rb')
-rw-r--r--app/models/diff_note_position.rb15
1 files changed, 13 insertions, 2 deletions
diff --git a/app/models/diff_note_position.rb b/app/models/diff_note_position.rb
index 78e4fbc49eb..716a56c6430 100644
--- a/app/models/diff_note_position.rb
+++ b/app/models/diff_note_position.rb
@@ -28,9 +28,20 @@ class DiffNotePosition < ApplicationRecord
end
def position=(position)
+ assign_attributes(self.class.position_to_attrs(position))
+ end
+
+ def self.create_or_update_for(note, params)
+ attrs = position_to_attrs(params[:position])
+ attrs.merge!(params.slice(:diff_type, :line_code))
+ attrs[:note_id] = note.id
+
+ upsert(attrs, unique_by: [:note_id, :diff_type])
+ end
+
+ def self.position_to_attrs(position)
position_attrs = position.to_h
position_attrs[:diff_content_type] = position_attrs.delete(:position_type)
-
- assign_attributes(position_attrs)
+ position_attrs
end
end