diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-04-25 14:28:23 +0200 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2016-05-29 15:03:00 -0400 |
commit | c31a296c94c48d865ce3171ccea9c48aa691466c (patch) | |
tree | 03990a269b380c85f46edb3eefbeae19bea8f970 | |
parent | f739a4e8718289f5a16d216e93021cf773c547bd (diff) | |
download | gitlab-ce-c31a296c94c48d865ce3171ccea9c48aa691466c.tar.gz |
Make note invalid if noteable project is different
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/15577
-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 |