removes hardcoded age, favours setting

This commit is contained in:
Juanjo Bazán
2017-01-09 16:05:27 +01:00
parent 220e7397e1
commit e2118f701b
9 changed files with 21 additions and 21 deletions

View File

@@ -23,7 +23,7 @@ class Verification::Management::Document
end
def valid_age?(response)
if under_sixteen?(response)
if under_age?(response)
errors.add(:age, true)
return false
else
@@ -31,8 +31,8 @@ class Verification::Management::Document
end
end
def under_sixteen?(response)
16.years.ago.beginning_of_day < response.date_of_birth.beginning_of_day
def under_age?(response)
User.minimum_required_age.years.ago.beginning_of_day < response.date_of_birth.beginning_of_day
end
def verified?

View File

@@ -36,7 +36,7 @@ class Verification::Residence
def allowed_age
return if errors[:date_of_birth].any?
errors.add(:date_of_birth, I18n.t('verification.residence.new.error_not_allowed_age')) unless self.date_of_birth <= 16.years.ago
errors.add(:date_of_birth, I18n.t('verification.residence.new.error_not_allowed_age')) unless self.date_of_birth <= User.minimum_required_age.years.ago
end
def document_number_uniqueness