Use double quotes in models
This commit is contained in:
@@ -22,14 +22,14 @@ class Verification::Letter
|
||||
|
||||
def validate_existing_user
|
||||
unless user
|
||||
errors.add(:email, I18n.t('devise.failure.invalid', authentication_keys: 'email'))
|
||||
errors.add(:email, I18n.t("devise.failure.invalid", authentication_keys: "email"))
|
||||
end
|
||||
end
|
||||
|
||||
def validate_correct_code
|
||||
return if errors.include?(:verification_code)
|
||||
if user.try(:letter_verification_code).to_i != verification_code.to_i
|
||||
errors.add(:verification_code, I18n.t('verification.letter.errors.incorrect_code'))
|
||||
errors.add(:verification_code, I18n.t("verification.letter.errors.incorrect_code"))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -40,9 +40,9 @@ class Verification::Management::Email
|
||||
def validate_user
|
||||
return if errors.count > 0
|
||||
if !user?
|
||||
errors.add(:email, I18n.t('errors.messages.user_not_found'))
|
||||
errors.add(:email, I18n.t("errors.messages.user_not_found"))
|
||||
elsif user.level_three_verified?
|
||||
errors.add(:email, I18n.t('management.email_verifications.already_verified'))
|
||||
errors.add(:email, I18n.t("management.email_verifications.already_verified"))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -50,7 +50,7 @@ class Verification::Management::Email
|
||||
return if errors.count > 0
|
||||
if document_number_mismatch?
|
||||
errors.add(:email,
|
||||
I18n.t('management.email_verifications.document_mismatch',
|
||||
I18n.t("management.email_verifications.document_mismatch",
|
||||
document_type: ApplicationController.helpers.humanize_document_type(user.document_type),
|
||||
document_number: user.document_number))
|
||||
end
|
||||
|
||||
@@ -2,9 +2,9 @@ class Verification::Management::ManagedUser
|
||||
include ActiveModel::Model
|
||||
|
||||
def self.find(document_type, document_number)
|
||||
User.where('document_number is not null').
|
||||
User.where("document_number is not null").
|
||||
find_or_initialize_by(document_type: document_type,
|
||||
document_number: document_number)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,8 +18,8 @@ class Verification::Residence
|
||||
validate :document_number_uniqueness
|
||||
|
||||
def initialize(attrs = {})
|
||||
self.date_of_birth = parse_date('date_of_birth', attrs)
|
||||
attrs = remove_date('date_of_birth', attrs)
|
||||
self.date_of_birth = parse_date("date_of_birth", attrs)
|
||||
attrs = remove_date("date_of_birth", attrs)
|
||||
super
|
||||
clean_document_number
|
||||
end
|
||||
@@ -39,11 +39,11 @@ class Verification::Residence
|
||||
|
||||
def allowed_age
|
||||
return if errors[:date_of_birth].any? || Age.in_years(date_of_birth) >= User.minimum_required_age
|
||||
errors.add(:date_of_birth, I18n.t('verification.residence.new.error_not_allowed_age'))
|
||||
errors.add(:date_of_birth, I18n.t("verification.residence.new.error_not_allowed_age"))
|
||||
end
|
||||
|
||||
def document_number_uniqueness
|
||||
errors.add(:document_number, I18n.t('errors.messages.taken')) if User.active.where(document_number: document_number).any?
|
||||
errors.add(:document_number, I18n.t("errors.messages.taken")) if User.active.where(document_number: document_number).any?
|
||||
end
|
||||
|
||||
def store_failed_attempt
|
||||
|
||||
Reference in New Issue
Block a user