diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-11 21:05:59 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-11 21:05:59 +0000 |
commit | ac062237da66db75b22f5dab2cc5766ee62a44d1 (patch) | |
tree | ae5a7eb248ddbf5c8c32c29a269127a936356364 /app/models/note.rb | |
parent | 0dfbcd8f8b1587a7e10eb79940a8dc13bd72c664 (diff) | |
download | gitlab-ce-ac062237da66db75b22f5dab2cc5766ee62a44d1.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/note.rb')
-rw-r--r-- | app/models/note.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/note.rb b/app/models/note.rb index edc4a332581..34736482387 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -104,6 +104,8 @@ class Note < ApplicationRecord end end + validate :does_not_exceed_notes_limit?, on: :create, unless: [:system?, :importing?] + # @deprecated attachments are handler by the MarkdownUploader mount_uploader :attachment, AttachmentUploader @@ -525,6 +527,12 @@ class Note < ApplicationRecord system_note_metadata&.cross_reference_types&.include?(system_note_metadata&.action) end + + def does_not_exceed_notes_limit? + return unless noteable + + errors.add(:base, _('Maximum number of comments exceeded')) if noteable.notes.count >= Noteable::MAX_NOTES_LIMIT + end end Note.prepend_if_ee('EE::Note') |