Commit 21af3855 authored by Kassio Borges's avatar Kassio Borges

Avoid exception when validating diff_note support

parent ab82aee6
......@@ -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