Fix bug with cross-reference note on commit

It should not set noteable_id if noteable_type is Commit
We have Note#commit_id for this
Signed-off-by: default avatarDmitriy Zaporozhets <>
parent eb2f3a80
......@@ -72,14 +72,20 @@ def create_status_change_note(noteable, project, author, status, source)
# +noteable+ was referenced from +mentioner+, by including GFM in either +mentioner+'s description or an associated Note.
# Create a system Note associated with +noteable+ with a GFM back-reference to +mentioner+.
def create_cross_reference_note(noteable, mentioner, author, project)
noteable: noteable,
commit_id: (noteable.sha if noteable.respond_to? :sha),
note_options = {
project: project,
author: author,
note: "_mentioned in #{mentioner.gfm_reference}_",
system: true
}, without_protection: true)
if noteable.kind_of?(Commit)
note_options.merge!(noteable_type: 'Commit', commit_id:
note_options.merge!(noteable: noteable)
create(note_options, without_protection: true)
def create_assignee_change_note(noteable, project, author, assignee)
......@@ -250,6 +250,16 @@
its(:project) { should == project }
its(:note) { should == "_mentioned in merge request !#{mergereq.iid}_" }
context 'commit from issue' do
subject { Note.create_cross_reference_note(commit, issue, author, project) }
it { should be_valid }
its(:noteable_type) { should == "Commit" }
its(:noteable_id) { should be_nil }
its(:commit_id) { should == }
its(:note) { should == "_mentioned in issue ##{issue.iid}_" }
describe '#cross_reference_exists?' 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