Commit 5a89bcc4 authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Avoid 500's when commit is not reachable

parent d9a761ed
......@@ -77,7 +77,7 @@ class DiffNote < Note
end
def supports_suggestion?
return false unless noteable.supports_suggestion? && on_text?
return false unless noteable&.supports_suggestion? && on_text?
# We don't want to trigger side-effects of `diff_file` call.
return false unless file = latest_diff_file
return false unless line = file.line_for_position(self.position)
......
---
title: Avoid 500 when rendering users ATOM data
merge_request: 25408
author:
type: fixed
......@@ -321,6 +321,14 @@ describe DiffNote do
end
describe '#supports_suggestion?' do
context 'when noteable does not exist' do
it 'returns false' do
allow(subject).to receive(:noteable) { nil }
expect(subject.supports_suggestion?).to be(false)
end
end
context 'when noteable does not support suggestions' do
it 'returns false' do
allow(subject.noteable).to receive(:supports_suggestion?) { false }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment