mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 04:37:30 +02:00
added tests
This commit is contained in:
parent
b0ed6167f5
commit
e9d7b40136
3 changed files with 51 additions and 19 deletions
|
@ -1,6 +1,8 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrantUserTest < ActiveSupport::TestCase
|
||||
Company = Struct.new(:registration_number, :company_name)
|
||||
|
||||
def setup
|
||||
super
|
||||
|
||||
|
@ -30,14 +32,34 @@ class RegistrantUserTest < ActiveSupport::TestCase
|
|||
assert_equal Country.new('US'), user.country
|
||||
end
|
||||
|
||||
def test_should_update_org_contact_if_data_from_business_registry_dismatch
|
||||
assert_equal 'US-1234', @user.registrant_ident
|
||||
org = contacts(:acme_ltd)
|
||||
org.ident_country_code = 'EE'
|
||||
org.save(validate: false)
|
||||
org.reload
|
||||
|
||||
company = Company.new(org.ident, "ace")
|
||||
|
||||
company_register = Minitest::Mock.new
|
||||
company_register.expect(:representation_rights, [company], [{ citizen_personal_code: '1234',
|
||||
citizen_country_code: 'USA' }])
|
||||
assert_equal [company], @user.companies(company_register)
|
||||
company_register.verify
|
||||
|
||||
org.reload
|
||||
end
|
||||
|
||||
def test_queries_company_register_for_associated_companies
|
||||
assert_equal 'US-1234', @user.registrant_ident
|
||||
|
||||
company = Company.new("acme", "ace")
|
||||
|
||||
company_register = Minitest::Mock.new
|
||||
company_register.expect(:representation_rights, %w[acme ace], [{ citizen_personal_code: '1234',
|
||||
company_register.expect(:representation_rights, [company], [{ citizen_personal_code: '1234',
|
||||
citizen_country_code: 'USA' }])
|
||||
|
||||
assert_equal %w[acme ace], @user.companies(company_register)
|
||||
assert_equal [company], @user.companies(company_register)
|
||||
company_register.verify
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue