summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-04-25 14:28:23 +0200
committerRobert Speicher <rspeicher@gmail.com>2016-05-29 15:03:00 -0400
commitc31a296c94c48d865ce3171ccea9c48aa691466c (patch)
tree03990a269b380c85f46edb3eefbeae19bea8f970
parentf739a4e8718289f5a16d216e93021cf773c547bd (diff)
downloadgitlab-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.rb6
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