Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-07-20 15:26:25 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-07-20 15:26:25 +0300
commita09983ae35713f5a2bbb100981116d31ce99826e (patch)
tree2ee2af7bd104d57086db360a7e6d8c9d5d43667a /app/models/user_detail.rb
parent18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff)
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'app/models/user_detail.rb')
-rw-r--r--app/models/user_detail.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/app/models/user_detail.rb b/app/models/user_detail.rb
index 5dc74421705..9674f9a41da 100644
--- a/app/models/user_detail.rb
+++ b/app/models/user_detail.rb
@@ -1,7 +1,33 @@
# frozen_string_literal: true
class UserDetail < ApplicationRecord
+ extend ::Gitlab::Utils::Override
+ include CacheMarkdownField
+
belongs_to :user
validates :job_title, length: { maximum: 200 }
+ validates :bio, length: { maximum: 255 }, allow_blank: true
+
+ before_save :prevent_nil_bio
+
+ cache_markdown_field :bio
+
+ def bio_html
+ read_attribute(:bio_html) || bio
+ end
+
+ # For backward compatibility.
+ # Older migrations (and their tests) reference the `User.migration_bot` where the `bio` attribute is set.
+ # Here we disable writing the markdown cache when the `bio_html` column does not exists.
+ override :invalidated_markdown_cache?
+ def invalidated_markdown_cache?
+ self.class.column_names.include?('bio_html') && super
+ end
+
+ private
+
+ def prevent_nil_bio
+ self.bio = '' if bio_changed? && bio.nil?
+ end
end