Add env variables to test and fix some of them

This commit is contained in:
riggraz
2019-09-24 12:57:32 +02:00
parent 2967b4eba0
commit c554d68f54
6 changed files with 41 additions and 31 deletions

View File

@@ -1,13 +1,13 @@
class User < ApplicationRecord
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
:recoverable, :rememberable, :validatable,
:confirmable
self.send(:devise, :confirmable) if Rails.application.email_confirmation?
has_many :comments
enum role: [:user, :moderator, :admin]
after_initialize :set_default_role, if: :new_record?
after_initialize :skip_confirmation, if: :new_record?
validates :full_name, presence: true, length: { in: 2..32 }
@@ -15,6 +15,13 @@ class User < ApplicationRecord
self.role ||= :user
end
def skip_confirmation
return if Rails.application.email_confirmation?
skip_confirmation!
skip_confirmation_notification!
skip_reconfirmation!
end
def gravatar_url
gravatar_id = Digest::MD5::hexdigest(email.downcase)
"https://secure.gravatar.com/avatar/#{gravatar_id}"