diff options
author | Robert Speicher <robert@gitlab.com> | 2016-08-19 18:15:47 +0000 |
---|---|---|
committer | Ruben Davila <rdavila84@gmail.com> | 2016-08-19 15:18:12 -0500 |
commit | fdb8b5f8c0f2549dce99c00989c29959c2d7e49e (patch) | |
tree | bc46cde41485e37aa1099ff3e61a0eb528cb3905 | |
parent | ba9dec025fe3d921c42477e5e3d3ada450c29b45 (diff) | |
download | gitlab-ce-fdb8b5f8c0f2549dce99c00989c29959c2d7e49e.tar.gz |
Merge branch 'fix-discussions-on-changed-lines' into 'master'
Fix bug where notes weren’t shown in discussion when the code had changed after creation
See merge request !5908
-rw-r--r-- | app/models/concerns/note_on_diff.rb | 4 | ||||
-rw-r--r-- | app/models/diff_note.rb | 4 | ||||
-rw-r--r-- | app/models/discussion.rb | 1 | ||||
-rw-r--r-- | app/models/legacy_diff_note.rb | 4 | ||||
-rw-r--r-- | app/views/discussions/_diff_with_notes.html.haml | 2 |
5 files changed, 14 insertions, 1 deletions
diff --git a/app/models/concerns/note_on_diff.rb b/app/models/concerns/note_on_diff.rb index 4be6a2f621b..a881fb83b7f 100644 --- a/app/models/concerns/note_on_diff.rb +++ b/app/models/concerns/note_on_diff.rb @@ -17,6 +17,10 @@ module NoteOnDiff raise NotImplementedError end + def original_line_code + raise NotImplementedError + end + def diff_attributes raise NotImplementedError end diff --git a/app/models/diff_note.rb b/app/models/diff_note.rb index f56c3d74ae3..aa54189fea9 100644 --- a/app/models/diff_note.rb +++ b/app/models/diff_note.rb @@ -57,6 +57,10 @@ class DiffNote < Note diff_file.position(line) == self.original_position end + def original_line_code + self.diff_file.line_code(self.diff_line) + end + def active?(diff_refs = nil) return false unless supported? return true if for_commit? diff --git a/app/models/discussion.rb b/app/models/discussion.rb index 3fddc084af2..9676bc03470 100644 --- a/app/models/discussion.rb +++ b/app/models/discussion.rb @@ -12,6 +12,7 @@ class Discussion :for_merge_request?, :line_code, + :original_line_code, :diff_file, :for_line?, :active?, diff --git a/app/models/legacy_diff_note.rb b/app/models/legacy_diff_note.rb index 8e26cbe9835..40277a9b139 100644 --- a/app/models/legacy_diff_note.rb +++ b/app/models/legacy_diff_note.rb @@ -49,6 +49,10 @@ class LegacyDiffNote < Note !line.meta? && diff_file.line_code(line) == self.line_code end + def original_line_code + self.line_code + end + # Check if this note is part of an "active" discussion # # This will always return true for anything except MergeRequest noteables, diff --git a/app/views/discussions/_diff_with_notes.html.haml b/app/views/discussions/_diff_with_notes.html.haml index b2e55f7647a..3a95a652810 100644 --- a/app/views/discussions/_diff_with_notes.html.haml +++ b/app/views/discussions/_diff_with_notes.html.haml @@ -7,7 +7,7 @@ .diff-content.code.js-syntax-highlight %table - - discussions = { discussion.line_code => discussion } + - discussions = { discussion.original_line_code => discussion } = render partial: "projects/diffs/line", collection: discussion.truncated_diff_lines, as: :line, |