summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-11 18:06:27 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-11 18:06:27 +0000
commitff67e3ed08355fb2d6f6e69d4ed06cd09052e573 (patch)
tree97ac29ddd32b612343b34bbdd6b8d57526b3d308 /app/models
parent7071f9bf3e131a7a668922ee450da529f1866b6f (diff)
downloadgitlab-ce-ff67e3ed08355fb2d6f6e69d4ed06cd09052e573.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r--app/models/abuse_report.rb4
-rw-r--r--app/models/award_emoji.rb5
2 files changed, 8 insertions, 1 deletions
diff --git a/app/models/abuse_report.rb b/app/models/abuse_report.rb
index a3a1748142f..7cfebf0473f 100644
--- a/app/models/abuse_report.rb
+++ b/app/models/abuse_report.rb
@@ -2,6 +2,7 @@
class AbuseReport < ApplicationRecord
include CacheMarkdownField
+ include Sortable
cache_markdown_field :message, pipeline: :single_line
@@ -13,6 +14,9 @@ class AbuseReport < ApplicationRecord
validates :message, presence: true
validates :user_id, uniqueness: { message: 'has already been reported' }
+ scope :by_user, -> (user) { where(user_id: user) }
+ scope :with_users, -> { includes(:reporter, :user) }
+
# For CacheMarkdownField
alias_method :author, :reporter
diff --git a/app/models/award_emoji.rb b/app/models/award_emoji.rb
index 24fcb97db6e..5a33a8f89df 100644
--- a/app/models/award_emoji.rb
+++ b/app/models/award_emoji.rb
@@ -6,11 +6,14 @@ class AwardEmoji < ApplicationRecord
include Participable
include GhostUser
+ include Importable
belongs_to :awardable, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations
belongs_to :user
- validates :awardable, :user, presence: true
+ validates :user, presence: true
+ validates :awardable, presence: true, unless: :importing?
+
validates :name, presence: true, inclusion: { in: Gitlab::Emoji.emojis_names }
validates :name, uniqueness: { scope: [:user, :awardable_type, :awardable_id] }, unless: :ghost_user?