mirror of
https://github.com/internetee/registry.git
synced 2025-08-12 04:29:33 +02:00
Fixed admin contact validation and repp error
This commit is contained in:
parent
8e8fd6cead
commit
537e75e162
4 changed files with 20 additions and 22 deletions
|
@ -33,8 +33,6 @@ class AdminDomainContact < DomainContact
|
||||||
def validate_contact_age
|
def validate_contact_age
|
||||||
return unless contact&.underage?
|
return unless contact&.underage?
|
||||||
|
|
||||||
errors.add(:contact, I18n.t(
|
errors.add(:base, :contact_too_young)
|
||||||
'activerecord.errors.models.admin_domain_contact.contact_too_young'
|
|
||||||
))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,6 +17,8 @@ module AgeValidation
|
||||||
def underage_by_birthday?
|
def underage_by_birthday?
|
||||||
birth_date = Date.parse(ident)
|
birth_date = Date.parse(ident)
|
||||||
calculate_age(birth_date) < 18
|
calculate_age(birth_date) < 18
|
||||||
|
rescue ArgumentError
|
||||||
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def underage_by_estonian_id?
|
def underage_by_estonian_id?
|
||||||
|
@ -24,6 +26,8 @@ module AgeValidation
|
||||||
|
|
||||||
birth_date = parse_estonian_id_birth_date(ident)
|
birth_date = parse_estonian_id_birth_date(ident)
|
||||||
calculate_age(birth_date) < 18
|
calculate_age(birth_date) < 18
|
||||||
|
rescue ArgumentError
|
||||||
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def estonian_id?
|
def estonian_id?
|
||||||
|
|
|
@ -3,11 +3,10 @@ class DomainContact < ApplicationRecord
|
||||||
# STI: admin_domain_contact
|
# STI: admin_domain_contact
|
||||||
include Versions # version/domain_contact_version.rb
|
include Versions # version/domain_contact_version.rb
|
||||||
include EppErrors
|
include EppErrors
|
||||||
|
|
||||||
belongs_to :contact
|
belongs_to :contact
|
||||||
belongs_to :domain
|
belongs_to :domain
|
||||||
|
|
||||||
validates :contact, presence: true
|
|
||||||
|
|
||||||
after_destroy :update_contact
|
after_destroy :update_contact
|
||||||
attr_accessor :value_typeahead
|
attr_accessor :value_typeahead
|
||||||
attr_writer :contact_code
|
attr_writer :contact_code
|
||||||
|
|
|
@ -27,8 +27,7 @@ class DomainContactTest < ActiveSupport::TestCase
|
||||||
)
|
)
|
||||||
|
|
||||||
assert_not domain_contact.valid?
|
assert_not domain_contact.valid?
|
||||||
assert_includes domain_contact.errors.full_messages,
|
assert_includes domain_contact.errors.full_messages, 'Administrative contact must be at least 18 years old'
|
||||||
'Contact Administrative contact must be at least 18 years old'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_validates_admin_contact_age_with_estonian_id
|
def test_validates_admin_contact_age_with_estonian_id
|
||||||
|
@ -45,8 +44,7 @@ class DomainContactTest < ActiveSupport::TestCase
|
||||||
)
|
)
|
||||||
|
|
||||||
assert_not domain_contact.valid?
|
assert_not domain_contact.valid?
|
||||||
assert_includes domain_contact.errors.full_messages,
|
assert_includes domain_contact.errors.full_messages, 'Administrative contact must be at least 18 years old'
|
||||||
'Contact Administrative contact must be at least 18 years old'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_allows_adult_admin_contact_with_birthday
|
def test_allows_adult_admin_contact_with_birthday
|
||||||
|
@ -79,5 +77,4 @@ class DomainContactTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
assert domain_contact.valid?
|
assert domain_contact.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
Loading…
Add table
Add a link
Reference in a new issue