mirror of
https://github.com/internetee/registry.git
synced 2025-07-28 13:36:15 +02:00
commit
feat: make technical contacts optional for all domains - Remove automatic tech contact assignment from admin contacts - Set minimum tech contacts to 0 for all registrant types - Update tests to reflect optional tech contacts - Keep max tech contacts limit from settings This change implements the requirement to make technical contacts optional for all domain types while maintaining the maximum limit from settings. Previously tech contacts were required for organizations and automatically copied from admin contacts.
This commit is contained in:
parent
c2affb393f
commit
cd5de3bd14
5 changed files with 42 additions and 9 deletions
|
@ -15,7 +15,7 @@ module Actions
|
|||
assign_registrant
|
||||
assign_nameservers
|
||||
assign_domain_contacts
|
||||
domain.attach_default_contacts
|
||||
# domain.attach_default_contacts
|
||||
assign_expiry_time
|
||||
maybe_attach_legal_doc
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ class Domain < ApplicationRecord
|
|||
|
||||
def self.tech_contacts_validation_rules(for_org:)
|
||||
{
|
||||
min: -> { for_org ? Setting.tech_contacts_min_count : 0 },
|
||||
min: -> { 0 },
|
||||
max: -> { Setting.tech_contacts_max_count }
|
||||
}
|
||||
end
|
||||
|
|
|
@ -381,6 +381,20 @@ class Epp::Domain < Domain
|
|||
|
||||
result
|
||||
end
|
||||
|
||||
def admin_contacts_validation_rules(for_org:)
|
||||
{
|
||||
min: -> { for_org ? Setting.admin_contacts_min_count : 0 },
|
||||
max: -> { Setting.admin_contacts_max_count }
|
||||
}
|
||||
end
|
||||
|
||||
def tech_contacts_validation_rules(for_org:)
|
||||
{
|
||||
min: 0,
|
||||
max: -> { Setting.tech_contacts_max_count }
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -391,4 +405,29 @@ class Epp::Domain < Domain
|
|||
|
||||
registrant.code != code
|
||||
end
|
||||
|
||||
def admin_contacts_validation_rules(for_org:)
|
||||
{
|
||||
min: -> { for_org ? Setting.admin_contacts_min_count : 0 },
|
||||
max: -> { Setting.admin_contacts_max_count }
|
||||
}
|
||||
end
|
||||
|
||||
def require_admin_contacts?
|
||||
return true if registrant.org?
|
||||
return false unless registrant.priv?
|
||||
|
||||
underage_registrant?
|
||||
end
|
||||
|
||||
def tech_contacts_validation_rules(for_org:)
|
||||
{
|
||||
min: 0, # Технический контакт опционален для всех
|
||||
max: -> { Setting.tech_contacts_max_count }
|
||||
}
|
||||
end
|
||||
|
||||
def require_tech_contacts?
|
||||
registrant.present? && registrant.org?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -639,7 +639,7 @@ class EppDomainCreateBaseTest < EppTestCase
|
|||
assert_equal name, domain.name
|
||||
assert_equal registrant, domain.registrant
|
||||
assert_equal [contact], domain.admin_contacts
|
||||
assert_equal [contact], domain.tech_contacts
|
||||
assert_empty domain.tech_contacts
|
||||
assert_not_empty domain.transfer_code
|
||||
|
||||
default_registration_period = 1.year + 1.day
|
||||
|
|
|
@ -235,9 +235,7 @@ class DomainTest < ActiveSupport::TestCase
|
|||
def test_validates_tech_contact_count
|
||||
domain_contact_attributes = domain_contacts(:shop_william).dup.attributes
|
||||
domain = valid_domain
|
||||
min_count = 1
|
||||
max_count = 2
|
||||
Setting.tech_contacts_min_count = min_count
|
||||
Setting.tech_contacts_max_count = max_count
|
||||
|
||||
domain.registrant.update!(ident_type: 'org')
|
||||
|
@ -245,16 +243,12 @@ class DomainTest < ActiveSupport::TestCase
|
|||
assert domain.registrant.org?
|
||||
|
||||
domain.tech_domain_contacts.clear
|
||||
min_count.times { domain.tech_domain_contacts.build(domain_contact_attributes) }
|
||||
assert domain.valid?, proc { domain.errors.full_messages }
|
||||
|
||||
domain.tech_domain_contacts.clear
|
||||
max_count.times { domain.tech_domain_contacts.build(domain_contact_attributes) }
|
||||
assert domain.valid?, proc { domain.errors.full_messages }
|
||||
|
||||
domain.tech_domain_contacts.clear
|
||||
assert domain.invalid?
|
||||
|
||||
domain.tech_domain_contacts.clear
|
||||
max_count.next.times { domain.tech_domain_contacts.build(domain_contact_attributes) }
|
||||
assert domain.invalid?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue