diff options
| author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-02-07 12:34:30 +0200 |
|---|---|---|
| committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-02-07 12:34:30 +0200 |
| commit | 4ecf30cd5b4731ed7735a658630729fd1c5fc993 (patch) | |
| tree | 025397f44e64848baf9674b0acc5b5a0913cd128 /app/models | |
| parent | eb2f3a804475f3bbcdf168aba7d13539bd7104c6 (diff) | |
| download | gitlab-ce-4ecf30cd5b4731ed7735a658630729fd1c5fc993.tar.gz | |
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: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/models')
| -rw-r--r-- | app/models/note.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/app/models/note.rb b/app/models/note.rb index f4c0be3307f..48c03c9d587 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -72,14 +72,20 @@ class Note < ActiveRecord::Base # +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) - create({ - 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: noteable.id) + else + note_options.merge!(noteable: noteable) + end + + create(note_options, without_protection: true) end def create_assignee_change_note(noteable, project, author, assignee) |
