diff options
Diffstat (limited to 'app/models/user.rb')
-rw-r--r-- | app/models/user.rb | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 4718e24d272..dcbf58123fe 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -55,13 +55,6 @@ class User < ActiveRecord::Base # - # Notification levels - # - N_DISABLED = 0 - N_PARTICIPATING = 1 - N_WATCH = 2 - - # # Relations # @@ -116,6 +109,9 @@ class User < ActiveRecord::Base format: { with: Gitlab::Regex.username_regex, message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" } + validates :notification_level, + inclusion: { in: Notification.notification_levels }, + presence: true validate :namespace_uniq, if: ->(user) { user.username_changed? } @@ -216,6 +212,10 @@ class User < ActiveRecord::Base username end + def notification + @notification ||= Notification.new(self) + end + def generate_password if self.force_random_password self.password = self.password_confirmation = Devise.friendly_token.first(8) |