Commit c31a296c authored by Grzegorz Bizon's avatar Grzegorz Bizon Committed by Robert Speicher

Make note invalid if noteable project is different

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/15577
parent f739a4e8
...@@ -33,6 +33,12 @@ class Note < ActiveRecord::Base ...@@ -33,6 +33,12 @@ class Note < ActiveRecord::Base
validates :commit_id, presence: true, if: ->(n) { n.noteable_type == 'Commit' } validates :commit_id, presence: true, if: ->(n) { n.noteable_type == 'Commit' }
validates :author, presence: true 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 mount_uploader :attachment, AttachmentUploader
# Scopes # Scopes
......
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