Extract company register

Closes #1079, #916, #1077
This commit is contained in:
Artur Beljajev 2019-02-09 16:35:01 +02:00
parent 8c4e6f1656
commit 83f8a9fb6a
44 changed files with 530 additions and 610 deletions

View file

@ -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