Commit 71a3c590 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'kassio/diff-note-avoid-exception-when-validating-style' into 'master'

Avoid exception when validating diff_note support

See merge request gitlab-org/gitlab!48187
parents f588a393 21af3855
......@@ -149,7 +149,7 @@ class DiffNote < Note
end
def supported?
for_commit? || for_design? || self.noteable.has_complete_diff_refs?
for_commit? || for_design? || self.noteable&.has_complete_diff_refs?
end
def set_line_code
......
---
title: Avoid exception when validating diff_note support
merge_request: 48187
author:
type: fixed
......@@ -38,6 +38,14 @@ RSpec.describe DiffNote do
it_behaves_like 'a valid diff positionable note' do
subject { build(:diff_note_on_commit, project: project, commit_id: commit_id, position: position) }
end
it "is not valid when noteable is empty" do
note = build(:diff_note_on_merge_request, project: project, noteable: nil)
note.valid?
expect(note.errors[:noteable]).to include("doesn't support new-style diff notes")
end
end
describe "#position=" do
......
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