summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2019-06-05 13:33:16 +0000
committerLin Jen-Shin <godfat@godfat.org>2019-06-05 13:33:16 +0000
commit09f482ba41b9dd021f1dc43a0ddf4ca3814bfc6b (patch)
tree363e0e4c953dfe10b7b2d63859cf31297ce9e757
parent202e525119188721004c4a1eb6be18c9cf7a6f5e (diff)
parent5a89bcc4dae55c40bdd926797aba5e3f0ada05ae (diff)
downloadgitlab-ce-09f482ba41b9dd021f1dc43a0ddf4ca3814bfc6b.tar.gz
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
-rw-r--r--app/models/diff_note.rb2
-rw-r--r--changelogs/unreleased/osw-avoid-500-on-suggestions-check.yml5
-rw-r--r--spec/models/diff_note_spec.rb8
3 files changed, 14 insertions, 1 deletions
diff --git a/app/models/diff_note.rb b/app/models/diff_note.rb
index 1a87fc47c56..8221b7de2b6 100644
--- a/app/models/diff_note.rb
+++ b/app/models/diff_note.rb
@@ -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)
diff --git a/changelogs/unreleased/osw-avoid-500-on-suggestions-check.yml b/changelogs/unreleased/osw-avoid-500-on-suggestions-check.yml
new file mode 100644
index 00000000000..d0a09385d4c
--- /dev/null
+++ b/changelogs/unreleased/osw-avoid-500-on-suggestions-check.yml
@@ -0,0 +1,5 @@
+---
+title: Avoid 500 when rendering users ATOM data
+merge_request: 25408
+author:
+type: fixed
diff --git a/spec/models/diff_note_spec.rb b/spec/models/diff_note_spec.rb
index fa19cb47a0d..d9e1fe4b165 100644
--- a/spec/models/diff_note_spec.rb
+++ b/spec/models/diff_note_spec.rb
@@ -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 }