summaryrefslogtreecommitdiff
path: root/app/models/note.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/note.rb')
-rw-r--r--app/models/note.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index 39645f8f1ad..e30be444eb5 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -40,13 +40,14 @@ class Note < ActiveRecord::Base
delegate :name, :email, to: :author, prefix: true
validates :note, :project, presence: true
+ validates :note, uniqueness: { scope: [:author, :noteable_type, :noteable_id] }, if: ->(n) { n.is_award }
validates :line_code, format: { with: /\A[a-z0-9]+_\d+_\d+\Z/ }, allow_blank: true
# Attachments are deprecated and are handled by Markdown uploader
validates :attachment, file_size: { maximum: :max_attachment_size }
validates :noteable_id, presence: true, if: ->(n) { n.noteable_type.present? && n.noteable_type != 'Commit' }
validates :commit_id, presence: true, if: ->(n) { n.noteable_type == 'Commit' }
- validates :author, presence: true, if: ->(n) { n.is_award }
+ validates :author, presence: true
mount_uploader :attachment, AttachmentUploader
@@ -102,7 +103,7 @@ class Note < ActiveRecord::Base
end
def grouped_awards
- select(:note).distinct.map do |note|
+ awards.select(:note).distinct.map do |note|
[ note.note, where(note: note.note) ]
end
end