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
|
||||
validate_ident
|
||||
maybe_change_email
|
||||
maybe_company_is_relevant
|
||||
# maybe_company_is_relevant
|
||||
commit
|
||||
validate_contact
|
||||
end
|
||||
|
@ -78,29 +78,16 @@ module Actions
|
|||
@error = true
|
||||
end
|
||||
|
||||
def maybe_company_is_relevant
|
||||
return true unless contact.org?
|
||||
# def maybe_company_is_relevant
|
||||
# return true unless contact.org?
|
||||
|
||||
Rails.logger.info "======= I AM HERE"
|
||||
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
|
||||
|
||||
company_status = contact.return_company_status
|
||||
Rails.logger.info "company_status: #{company_status}"
|
||||
# return if [Contact::REGISTERED, Contact::LIQUIDATED].include? 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
|
||||
Rails.logger.info Contact::REGISTERED
|
||||
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
|
||||
# @error = true
|
||||
# end
|
||||
|
||||
def maybe_attach_legal_doc
|
||||
::Actions::BaseAction.attach_legal_doc_to_new(contact, legal_document, domain: false)
|
||||
|
|
|
@ -11,26 +11,16 @@ module Contact::CompanyRegister
|
|||
end
|
||||
|
||||
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_company_data.first[:status]
|
||||
end
|
||||
|
||||
def return_company_data
|
||||
Rails.logger.info "inside return_company_data"
|
||||
Rails.logger.info "ident: #{ident}"
|
||||
Rails.logger.info "org?: #{org?}"
|
||||
return unless org?
|
||||
|
||||
res = company_register.simple_data(registration_number: ident.to_s)
|
||||
Rails.logger.info "res: #{res.inspect}"
|
||||
res
|
||||
company_register.simple_data(registration_number: ident.to_s)
|
||||
rescue CompanyRegister::NotAvailableError
|
||||
Rails.logger.info "ERROR HAPPENED: CompanyRegister::NotAvailableError"
|
||||
[]
|
||||
end
|
||||
|
||||
|
|
|
@ -188,39 +188,39 @@ class ReppV1ContactsCreateTest < ActionDispatch::IntegrationTest
|
|||
ENV['shunter_enabled'] = 'false'
|
||||
end
|
||||
|
||||
def test_returns_error_response_if_company_not_existed
|
||||
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
|
||||
# def test_returns_error_response_if_company_not_existed
|
||||
# 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',
|
||||
},
|
||||
},
|
||||
}
|
||||
# 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)
|
||||
# post '/repp/v1/contacts', headers: @auth_headers, params: request_body
|
||||
# json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :bad_request
|
||||
assert_equal 2003, json[:code]
|
||||
puts json[:message]
|
||||
assert json[:message].include? 'Company is not registered'
|
||||
# assert_response :bad_request
|
||||
# assert_equal 2003, json[:code]
|
||||
# puts json[:message]
|
||||
# assert json[:message].include? 'Company is not registered'
|
||||
|
||||
CompanyRegister::Client.define_singleton_method(:new, original_new_method)
|
||||
end
|
||||
# CompanyRegister::Client.define_singleton_method(:new, original_new_method)
|
||||
# end
|
||||
|
||||
def test_contact_created_with_existed_company
|
||||
original_new_method = CompanyRegister::Client.method(:new)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue