diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/note.rb | 2 | ||||
-rw-r--r-- | app/models/snippet.rb | 1 | ||||
-rw-r--r-- | app/models/user.rb | 2 | ||||
-rw-r--r-- | app/models/user_status.rb | 17 |
4 files changed, 21 insertions, 1 deletions
diff --git a/app/models/note.rb b/app/models/note.rb index fe3507adcb3..87cf7c7b2fa 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -101,7 +101,7 @@ class Note < ActiveRecord::Base scope :inc_author_project, -> { includes(:project, :author) } scope :inc_author, -> { includes(:author) } scope :inc_relations_for_view, -> do - includes(:project, :author, :updated_by, :resolved_by, :award_emoji, + includes(:project, { author: :status }, :updated_by, :resolved_by, :award_emoji, :system_note_metadata, :note_diff_file) end diff --git a/app/models/snippet.rb b/app/models/snippet.rb index 644120453cf..390bdbf838a 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -49,6 +49,7 @@ class Snippet < ActiveRecord::Base scope :are_public, -> { where(visibility_level: Snippet::PUBLIC) } scope :public_and_internal, -> { where(visibility_level: [Snippet::PUBLIC, Snippet::INTERNAL]) } scope :fresh, -> { order("created_at DESC") } + scope :inc_relations_for_view, -> { includes(author: :status) } participant :author participant :notes_with_associations diff --git a/app/models/user.rb b/app/models/user.rb index 03549872924..31b49b9bf2a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -141,6 +141,8 @@ class User < ActiveRecord::Base has_many :term_agreements belongs_to :accepted_term, class_name: 'ApplicationSetting::Term' + has_one :status, class_name: 'UserStatus' + # # Validations # diff --git a/app/models/user_status.rb b/app/models/user_status.rb new file mode 100644 index 00000000000..2bbb0c59ac1 --- /dev/null +++ b/app/models/user_status.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class UserStatus < ActiveRecord::Base + include CacheMarkdownField + + self.primary_key = :user_id + + DEFAULT_EMOJI = 'speech_balloon'.freeze + + belongs_to :user + + validates :user, presence: true + validates :emoji, inclusion: { in: Gitlab::Emoji.emojis_names } + validates :message, length: { maximum: 100 }, allow_blank: true + + cache_markdown_field :message, pipeline: :emoji +end |