mirror of
https://github.com/internetee/registry.git
synced 2025-07-27 21:16:12 +02:00
remove company creation validation
This commit is contained in:
parent
d23b66e859
commit
d0a39bf469
3 changed files with 38 additions and 61 deletions
|
@ -14,7 +14,7 @@ module Actions
|
||||||
maybe_attach_legal_doc
|
maybe_attach_legal_doc
|
||||||
validate_ident
|
validate_ident
|
||||||
maybe_change_email
|
maybe_change_email
|
||||||
maybe_company_is_relevant
|
# maybe_company_is_relevant
|
||||||
commit
|
commit
|
||||||
validate_contact
|
validate_contact
|
||||||
end
|
end
|
||||||
|
@ -78,29 +78,16 @@ module Actions
|
||||||
@error = true
|
@error = true
|
||||||
end
|
end
|
||||||
|
|
||||||
def maybe_company_is_relevant
|
# def maybe_company_is_relevant
|
||||||
return true unless contact.org?
|
# return true unless contact.org?
|
||||||
|
|
||||||
Rails.logger.info "======= I AM HERE"
|
# company_status = contact.return_company_status
|
||||||
Rails.logger.info ENV['company_register_username']
|
|
||||||
Rails.logger.info ENV['company_register_password']
|
|
||||||
Rails.logger.info ENV['company_register_cache_period_days']
|
|
||||||
Rails.logger.info ENV['company_register_test_mode']
|
|
||||||
|
|
||||||
company_status = contact.return_company_status
|
# return if [Contact::REGISTERED, Contact::LIQUIDATED].include? company_status
|
||||||
Rails.logger.info "company_status: #{company_status}"
|
# contact.add_epp_error('2003', nil, 'ident', I18n.t('errors.messages.company_not_registered'))
|
||||||
|
|
||||||
return if [Contact::REGISTERED, Contact::LIQUIDATED].include? company_status
|
# @error = true
|
||||||
Rails.logger.info Contact::REGISTERED
|
# end
|
||||||
Rails.logger.info Contact::LIQUIDATED
|
|
||||||
Rails.logger.info "======= I AM HERE 2"
|
|
||||||
|
|
||||||
contact.add_epp_error('2003', nil, 'ident', I18n.t('errors.messages.company_not_registered'))
|
|
||||||
|
|
||||||
Rails.logger.info "======="
|
|
||||||
|
|
||||||
@error = true
|
|
||||||
end
|
|
||||||
|
|
||||||
def maybe_attach_legal_doc
|
def maybe_attach_legal_doc
|
||||||
::Actions::BaseAction.attach_legal_doc_to_new(contact, legal_document, domain: false)
|
::Actions::BaseAction.attach_legal_doc_to_new(contact, legal_document, domain: false)
|
||||||
|
|
|
@ -11,26 +11,16 @@ module Contact::CompanyRegister
|
||||||
end
|
end
|
||||||
|
|
||||||
def return_company_status
|
def return_company_status
|
||||||
Rails.logger.info "ident: #{ident}"
|
|
||||||
Rails.logger.info "org?: #{org?}"
|
|
||||||
Rails.logger.info "return_company_data: #{return_company_data.inspect}"
|
|
||||||
|
|
||||||
return if return_company_data.blank?
|
return if return_company_data.blank?
|
||||||
|
|
||||||
return_company_data.first[:status]
|
return_company_data.first[:status]
|
||||||
end
|
end
|
||||||
|
|
||||||
def return_company_data
|
def return_company_data
|
||||||
Rails.logger.info "inside return_company_data"
|
|
||||||
Rails.logger.info "ident: #{ident}"
|
|
||||||
Rails.logger.info "org?: #{org?}"
|
|
||||||
return unless org?
|
return unless org?
|
||||||
|
|
||||||
res = company_register.simple_data(registration_number: ident.to_s)
|
company_register.simple_data(registration_number: ident.to_s)
|
||||||
Rails.logger.info "res: #{res.inspect}"
|
|
||||||
res
|
|
||||||
rescue CompanyRegister::NotAvailableError
|
rescue CompanyRegister::NotAvailableError
|
||||||
Rails.logger.info "ERROR HAPPENED: CompanyRegister::NotAvailableError"
|
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -188,39 +188,39 @@ class ReppV1ContactsCreateTest < ActionDispatch::IntegrationTest
|
||||||
ENV['shunter_enabled'] = 'false'
|
ENV['shunter_enabled'] = 'false'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_returns_error_response_if_company_not_existed
|
# def test_returns_error_response_if_company_not_existed
|
||||||
original_new_method = CompanyRegister::Client.method(:new)
|
# original_new_method = CompanyRegister::Client.method(:new)
|
||||||
CompanyRegister::Client.define_singleton_method(:new) do
|
# CompanyRegister::Client.define_singleton_method(:new) do
|
||||||
object = original_new_method.call
|
# object = original_new_method.call
|
||||||
def object.simple_data(registration_number:)
|
# def object.simple_data(registration_number:)
|
||||||
[Company.new('1234567', 'ACME Ltd', 'K')]
|
# [Company.new('1234567', 'ACME Ltd', 'K')]
|
||||||
end
|
# end
|
||||||
object
|
# object
|
||||||
end
|
# end
|
||||||
|
|
||||||
request_body = {
|
# request_body = {
|
||||||
"contact": {
|
# "contact": {
|
||||||
"name": 'Donald Trump',
|
# "name": 'Donald Trump',
|
||||||
"phone": '+372.51111112',
|
# "phone": '+372.51111112',
|
||||||
"email": 'donald@trumptower.com',
|
# "email": 'donald@trumptower.com',
|
||||||
"ident": {
|
# "ident": {
|
||||||
"ident_type": 'org',
|
# "ident_type": 'org',
|
||||||
"ident_country_code": 'EE',
|
# "ident_country_code": 'EE',
|
||||||
"ident": '70000313',
|
# "ident": '70000313',
|
||||||
},
|
# },
|
||||||
},
|
# },
|
||||||
}
|
# }
|
||||||
|
|
||||||
post '/repp/v1/contacts', headers: @auth_headers, params: request_body
|
# post '/repp/v1/contacts', headers: @auth_headers, params: request_body
|
||||||
json = JSON.parse(response.body, symbolize_names: true)
|
# json = JSON.parse(response.body, symbolize_names: true)
|
||||||
|
|
||||||
assert_response :bad_request
|
# assert_response :bad_request
|
||||||
assert_equal 2003, json[:code]
|
# assert_equal 2003, json[:code]
|
||||||
puts json[:message]
|
# puts json[:message]
|
||||||
assert json[:message].include? 'Company is not registered'
|
# assert json[:message].include? 'Company is not registered'
|
||||||
|
|
||||||
CompanyRegister::Client.define_singleton_method(:new, original_new_method)
|
# CompanyRegister::Client.define_singleton_method(:new, original_new_method)
|
||||||
end
|
# end
|
||||||
|
|
||||||
def test_contact_created_with_existed_company
|
def test_contact_created_with_existed_company
|
||||||
original_new_method = CompanyRegister::Client.method(:new)
|
original_new_method = CompanyRegister::Client.method(:new)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue