diff options
-rw-r--r-- | app/models/note.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/app/models/note.rb b/app/models/note.rb index 55b98557244..8743b5eb472 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -33,6 +33,12 @@ class Note < ActiveRecord::Base validates :commit_id, presence: true, if: ->(n) { n.noteable_type == 'Commit' } validates :author, presence: true + validate do |note| + unless note.noteable.project == project + errors.add(:invalid_project, 'Note and noteable project mismatch') + end + end + mount_uploader :attachment, AttachmentUploader # Scopes |