diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-07-15 23:49:24 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-07-15 23:49:24 +0000 |
commit | 4f25e3178b2eaa71f312e80ca183358b350c97d6 (patch) | |
tree | 054d7a2d19a5705c1b9ee253c438218c194d7650 | |
parent | c676283b7aa5428949d81aba2bd248102e600f1b (diff) | |
parent | 34653c1e8be0be230943c39713da424a9e22d15b (diff) | |
download | gitlab-ce-4f25e3178b2eaa71f312e80ca183358b350c97d6.tar.gz |
Merge branch 'legacy-diff-notes-are-dumb' into 'master'
Don't fail when a LegacyDiffNote didn't store the right diff
Fixes https://sentry.gitlap.com/gitlab/gitlabcom/issues/8865/ and https://sentry.gitlap.com/gitlab/gitlabcom/issues/8754/
See merge request !5287
-rw-r--r-- | app/models/legacy_diff_note.rb | 4 | ||||
-rw-r--r-- | app/views/notify/note_merge_request_email.html.haml | 2 | ||||
-rw-r--r-- | spec/models/legacy_diff_note_spec.rb | 8 |
3 files changed, 7 insertions, 7 deletions
diff --git a/app/models/legacy_diff_note.rb b/app/models/legacy_diff_note.rb index 790dfd4d480..04a651d50ab 100644 --- a/app/models/legacy_diff_note.rb +++ b/app/models/legacy_diff_note.rb @@ -38,7 +38,7 @@ class LegacyDiffNote < Note end def diff_line - @diff_line ||= diff_file.line_for_line_code(self.line_code) + @diff_line ||= diff_file.line_for_line_code(self.line_code) if diff_file end def for_line?(line) @@ -55,7 +55,7 @@ class LegacyDiffNote < Note def active? return @active if defined?(@active) return true if for_commit? - return true unless self.diff + return true unless diff_line return false unless noteable noteable_diff = find_noteable_diff diff --git a/app/views/notify/note_merge_request_email.html.haml b/app/views/notify/note_merge_request_email.html.haml index 35c4b862bb7..ea7e3d199fd 100644 --- a/app/views/notify/note_merge_request_email.html.haml +++ b/app/views/notify/note_merge_request_email.html.haml @@ -1,4 +1,4 @@ -- if @note.diff_note? +- if @note.diff_note? && @note.diff_file %p.details New comment on diff for = link_to @note.diff_file.file_path, @target_url diff --git a/spec/models/legacy_diff_note_spec.rb b/spec/models/legacy_diff_note_spec.rb index d64d89edbd3..d23fc06c3ad 100644 --- a/spec/models/legacy_diff_note_spec.rb +++ b/spec/models/legacy_diff_note_spec.rb @@ -16,10 +16,10 @@ describe LegacyDiffNote, models: true do end describe '#active?' do - it 'is always true when the note has no associated diff' do + it 'is always true when the note has no associated diff line' do note = build(:legacy_diff_note_on_merge_request) - expect(note).to receive(:diff).and_return(nil) + expect(note).to receive(:diff_line).and_return(nil) expect(note).to be_active end @@ -27,7 +27,7 @@ describe LegacyDiffNote, models: true do it 'is never true when the note has no noteable associated' do note = build(:legacy_diff_note_on_merge_request) - expect(note).to receive(:diff).and_return(double) + expect(note).to receive(:diff_line).and_return(double) expect(note).to receive(:noteable).and_return(nil) expect(note).not_to be_active @@ -47,7 +47,7 @@ describe LegacyDiffNote, models: true do merge = build_stubbed(:merge_request, :simple) note = build(:legacy_diff_note_on_merge_request, noteable: merge) - allow(note).to receive(:diff).and_return(double) + allow(note).to receive(:diff_line).and_return(double) expect(note).to receive(:find_noteable_diff).and_return(nil) expect(note).not_to be_active |