Commit 09f482ba authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'osw-avoid-500-on-suggestions-check' into 'master'

Avoid 500 when evaluating `DiffNote#supports_suggestion?` and commit is not reachable

Closes #57570

See merge request gitlab-org/gitlab-ce!25408
parents 202e5251 5a89bcc4
......@@ -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