diff options
author | Felipe Artur <fcardozo@gitlab.com> | 2017-10-07 04:25:17 +0000 |
---|---|---|
committer | Jacob Schatz <jschatz@gitlab.com> | 2017-10-07 04:25:17 +0000 |
commit | b54203f0ada8f7ad6d24437b6f5f46ebf43f8695 (patch) | |
tree | b903596b4755da406dfd1349a8b2c59a5f38b9d1 /app/models/diff_note.rb | |
parent | b4f9dc48163c065d776d120dd312c689ce79f653 (diff) | |
download | gitlab-ce-b54203f0ada8f7ad6d24437b6f5f46ebf43f8695.tar.gz |
Commenting on image diffs
Diffstat (limited to 'app/models/diff_note.rb')
-rw-r--r-- | app/models/diff_note.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/app/models/diff_note.rb b/app/models/diff_note.rb index e9a60e6ce09..d88a92dc027 100644 --- a/app/models/diff_note.rb +++ b/app/models/diff_note.rb @@ -12,8 +12,8 @@ class DiffNote < Note validates :original_position, presence: true validates :position, presence: true - validates :diff_line, presence: true - validates :line_code, presence: true, line_code: true + validates :diff_line, presence: true, if: :on_text? + validates :line_code, presence: true, line_code: true, if: :on_text? validates :noteable_type, inclusion: { in: NOTEABLE_TYPES } validate :positions_complete validate :verify_supported @@ -43,6 +43,14 @@ class DiffNote < Note end end + def on_text? + position.position_type == "text" + end + + def on_image? + position.position_type == "image" + end + def diff_file @diff_file ||= self.original_position.diff_file(self.project.repository) end @@ -56,6 +64,8 @@ class DiffNote < Note end def original_line_code + return unless on_text? + self.diff_file.line_code(self.diff_line) end |