mirror of
https://github.com/internetee/registry.git
synced 2025-07-27 04:58:29 +02:00
feat: add ability to skip business contact validation
- Add environment variable 'allow_validate_business_contacts' to control business contact validation - Remove redundant company_is_relevant? method - Add integration test for skipping company validation
This commit is contained in:
parent
ebc9fd4871
commit
c77a4d494d
4 changed files with 39 additions and 4 deletions
|
@ -80,6 +80,7 @@ module Actions
|
|||
end
|
||||
|
||||
def maybe_company_is_relevant
|
||||
return true if ENV['allow_validate_business_contacts'] && ENV['allow_validate_business_contacts'] == 'false'
|
||||
return true unless contact.org?
|
||||
return true unless contact.ident_country_code == 'EE'
|
||||
|
||||
|
|
|
@ -6,10 +6,6 @@ module Contact::CompanyRegister
|
|||
BANKRUPT = 'N'.freeze
|
||||
DELETED = 'K'.freeze
|
||||
|
||||
def company_is_relevant?
|
||||
company_register_status == REGISTERED && company_register_status == LIQUIDATED
|
||||
end
|
||||
|
||||
def return_company_status
|
||||
return if return_company_data.blank?
|
||||
|
||||
|
|
|
@ -265,3 +265,5 @@ priv_ident_service_client_id: 123
|
|||
priv_ident_service_client_secret: 321
|
||||
birthday_ident_service_client_id: 456
|
||||
birthday_ident_service_client_secret: 654
|
||||
|
||||
allow_validate_business_contacts: 'true'
|
|
@ -221,6 +221,42 @@ class ReppV1ContactsCreateTest < ActionDispatch::IntegrationTest
|
|||
CompanyRegister::Client.define_singleton_method(:new, original_new_method)
|
||||
end
|
||||
|
||||
def test_skip_company_validation_if_flag_is_set
|
||||
ENV['allow_validate_business_contacts'] = 'false'
|
||||
original_new_method = CompanyRegister::Client.method(:new)
|
||||
CompanyRegister::Client.define_singleton_method(:new) do
|
||||
object = original_new_method.call
|
||||
def object.simple_data(registration_number:)
|
||||
[Company.new('1234567', 'ACME Ltd', 'K')]
|
||||
end
|
||||
object
|
||||
end
|
||||
|
||||
request_body = {
|
||||
"contact": {
|
||||
"name": 'Donald Trump',
|
||||
"phone": '+372.51111112',
|
||||
"email": 'donald@trumptower.com',
|
||||
"ident": {
|
||||
"ident_type": 'org',
|
||||
"ident_country_code": 'EE',
|
||||
"ident": '70000313',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
post '/repp/v1/contacts', headers: @auth_headers, params: request_body
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 1000, json[:code]
|
||||
assert_equal 'Command completed successfully', json[:message]
|
||||
|
||||
CompanyRegister::Client.define_singleton_method(:new, original_new_method)
|
||||
ENV['allow_validate_business_contacts'] = 'true'
|
||||
end
|
||||
|
||||
|
||||
def test_contact_created_with_existed_company
|
||||
original_new_method = CompanyRegister::Client.method(:new)
|
||||
CompanyRegister::Client.define_singleton_method(:new) do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue