mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 05:34:46 +02:00
parent
8c4e6f1656
commit
83f8a9fb6a
44 changed files with 530 additions and 610 deletions
|
@ -9,6 +9,14 @@ class ContactTest < ActiveSupport::TestCase
|
|||
assert @contact.valid?, proc { @contact.errors.full_messages }
|
||||
end
|
||||
|
||||
def test_private_entity
|
||||
assert_equal 'priv', Contact::PRIV
|
||||
end
|
||||
|
||||
def test_legal_entity
|
||||
assert_equal 'org', Contact::ORG
|
||||
end
|
||||
|
||||
def test_invalid_without_email
|
||||
@contact.email = ''
|
||||
assert @contact.invalid?
|
||||
|
@ -48,4 +56,27 @@ class ContactTest < ActiveSupport::TestCase
|
|||
assert_equal 'EE', @contact.country_code
|
||||
assert_equal address, @contact.address
|
||||
end
|
||||
end
|
||||
|
||||
def test_returns_registrant_user_direct_contacts
|
||||
assert_equal Contact::PRIV, @contact.ident_type
|
||||
assert_equal '1234', @contact.ident
|
||||
assert_equal 'US', @contact.ident_country_code
|
||||
registrant_user = RegistrantUser.new(registrant_ident: 'US-1234')
|
||||
|
||||
registrant_user.stub(:companies, []) do
|
||||
assert_equal [@contact], Contact.registrant_user_contacts(registrant_user)
|
||||
assert_equal [@contact], Contact.registrant_user_direct_contacts(registrant_user)
|
||||
end
|
||||
end
|
||||
|
||||
def test_returns_registrant_user_indirect_contacts
|
||||
@contact.update!(ident_type: Contact::ORG)
|
||||
assert_equal '1234', @contact.ident
|
||||
assert_equal 'US', @contact.ident_country_code
|
||||
registrant_user = RegistrantUser.new(registrant_ident: 'US-1234')
|
||||
|
||||
registrant_user.stub(:companies, [OpenStruct.new(registration_number: '1234')]) do
|
||||
assert_equal [@contact], Contact.registrant_user_contacts(registrant_user)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -17,4 +17,57 @@ class DomainTest < ActiveSupport::TestCase
|
|||
domain = Domain.new(name: 'shop.test')
|
||||
assert_equal 'shop.test', domain.domain_name.to_s
|
||||
end
|
||||
end
|
||||
|
||||
def test_returns_registrant_user_domains_by_registrant
|
||||
registrant = contacts(:john).becomes(Registrant)
|
||||
assert_equal registrant, @domain.registrant
|
||||
registrant_user = RegistrantUser.new
|
||||
|
||||
registrant_user.stub(:contacts, [registrant]) do
|
||||
assert_includes Domain.registrant_user_domains(registrant_user), @domain
|
||||
end
|
||||
end
|
||||
|
||||
def test_returns_registrant_user_domains_by_contact
|
||||
contact = contacts(:jane)
|
||||
assert_not_equal contact.becomes(Registrant), @domain.registrant
|
||||
assert_includes @domain.contacts, contact
|
||||
registrant_user = RegistrantUser.new
|
||||
|
||||
registrant_user.stub(:contacts, [contact]) do
|
||||
assert_includes Domain.registrant_user_domains(registrant_user), @domain
|
||||
end
|
||||
end
|
||||
|
||||
def test_returns_registrant_user_administered_domains_by_registrant
|
||||
registrant = contacts(:john).becomes(Registrant)
|
||||
assert_equal registrant, @domain.registrant
|
||||
registrant_user = RegistrantUser.new
|
||||
|
||||
registrant_user.stub(:contacts, [registrant]) do
|
||||
assert_includes Domain.registrant_user_administered_domains(registrant_user), @domain
|
||||
end
|
||||
end
|
||||
|
||||
def test_returns_registrant_user_administered_domains_by_administrative_contact
|
||||
contact = contacts(:jane)
|
||||
assert_not_equal contact.becomes(Registrant), @domain.registrant
|
||||
assert_includes @domain.admin_contacts, contact
|
||||
registrant_user = RegistrantUser.new
|
||||
|
||||
registrant_user.stub(:contacts, [contact]) do
|
||||
assert_includes Domain.registrant_user_administered_domains(registrant_user), @domain
|
||||
end
|
||||
end
|
||||
|
||||
def test_does_not_return_registrant_user_administered_domains_by_technical_contact
|
||||
contact = contacts(:william)
|
||||
assert_not_equal contact.becomes(Registrant), @domain.registrant
|
||||
assert_includes @domain.tech_contacts, contact
|
||||
registrant_user = RegistrantUser.new
|
||||
|
||||
registrant_user.stub(:contacts, [contact]) do
|
||||
assert_not_includes Domain.registrant_user_administered_domains(registrant_user), @domain
|
||||
end
|
||||
end
|
||||
end
|
|
@ -11,29 +11,8 @@ class RegistrantUserTest < ActiveSupport::TestCase
|
|||
super
|
||||
end
|
||||
|
||||
def test_domains_returns_an_list_of_distinct_domains_associated_with_a_specific_id_code
|
||||
domain_names = @user.domains.pluck(:name)
|
||||
assert_equal(4, domain_names.length)
|
||||
|
||||
# User is a registrant, but not a contact for the domain. Should be included in the list.
|
||||
assert(domain_names.include?('shop.test'))
|
||||
end
|
||||
|
||||
def test_administered_domains_returns_a_list_of_domains
|
||||
domain_names = @user.administered_domains.pluck(:name)
|
||||
assert_equal(3, domain_names.length)
|
||||
|
||||
# User is a tech contact for the domain.
|
||||
refute(domain_names.include?('library.test'))
|
||||
end
|
||||
|
||||
def test_contacts_returns_an_list_of_contacts_associated_with_a_specific_id_code
|
||||
assert_equal(1, @user.contacts.count)
|
||||
end
|
||||
|
||||
def test_ident_and_country_code_helper_methods
|
||||
def test_ident_helper_method
|
||||
assert_equal('1234', @user.ident)
|
||||
assert_equal('US', @user.country_code)
|
||||
end
|
||||
|
||||
def test_first_name_from_username
|
||||
|
@ -45,4 +24,44 @@ class RegistrantUserTest < ActiveSupport::TestCase
|
|||
user = RegistrantUser.new(username: 'John Doe')
|
||||
assert_equal 'Doe', user.last_name
|
||||
end
|
||||
end
|
||||
|
||||
def test_returns_country
|
||||
user = RegistrantUser.new(registrant_ident: 'US-1234')
|
||||
assert_equal Country.new('US'), user.country
|
||||
end
|
||||
|
||||
def test_queries_company_register_for_associated_companies
|
||||
assert_equal 'US-1234', @user.registrant_ident
|
||||
|
||||
company_register = Minitest::Mock.new
|
||||
company_register.expect(:representation_rights, %w[acme ace], [{ citizen_personal_code: '1234',
|
||||
citizen_country_code: 'USA' }])
|
||||
|
||||
assert_equal %w[acme ace], @user.companies(company_register)
|
||||
company_register.verify
|
||||
end
|
||||
|
||||
def test_returns_contacts
|
||||
Contact.stub(:registrant_user_contacts, %w(john jane)) do
|
||||
assert_equal %w(john jane), @user.contacts
|
||||
end
|
||||
end
|
||||
|
||||
def test_returns_direct_contacts
|
||||
Contact.stub(:registrant_user_direct_contacts, %w(john jane)) do
|
||||
assert_equal %w(john jane), @user.direct_contacts
|
||||
end
|
||||
end
|
||||
|
||||
def test_returns_domains
|
||||
Domain.stub(:registrant_user_domains, %w(shop airport)) do
|
||||
assert_equal %w(shop airport), @user.domains
|
||||
end
|
||||
end
|
||||
|
||||
def test_returns_administered_domains
|
||||
Domain.stub(:registrant_user_administered_domains, %w(shop airport)) do
|
||||
assert_equal %w(shop airport), @user.administered_domains
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue