From d0a39bf4693d4245e5f1ed9fb66f80ba0ff1a422 Mon Sep 17 00:00:00 2001 From: oleghasjanov Date: Mon, 25 Nov 2024 14:48:28 +0200 Subject: [PATCH] remove company creation validation --- app/interactions/actions/contact_create.rb | 29 +++----- app/models/contact/company_register.rb | 12 +--- .../repp/v1/contacts/create_test.rb | 66 +++++++++---------- 3 files changed, 42 insertions(+), 65 deletions(-) diff --git a/app/interactions/actions/contact_create.rb b/app/interactions/actions/contact_create.rb index c29b0bb84b..39fb3212d8 100644 --- a/app/interactions/actions/contact_create.rb +++ b/app/interactions/actions/contact_create.rb @@ -14,7 +14,7 @@ def call 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 @@ def validate_ident_birthday @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) diff --git a/app/models/contact/company_register.rb b/app/models/contact/company_register.rb index 42b731fcae..4f036dd973 100644 --- a/app/models/contact/company_register.rb +++ b/app/models/contact/company_register.rb @@ -11,26 +11,16 @@ def company_is_relevant? 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 diff --git a/test/integration/repp/v1/contacts/create_test.rb b/test/integration/repp/v1/contacts/create_test.rb index aa252ddca0..e47b962651 100644 --- a/test/integration/repp/v1/contacts/create_test.rb +++ b/test/integration/repp/v1/contacts/create_test.rb @@ -188,39 +188,39 @@ def test_returns_error_response_if_throttled 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 - - 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 :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 + # 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', + # }, + # }, + # } + + # 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' + + # CompanyRegister::Client.define_singleton_method(:new, original_new_method) + # end def test_contact_created_with_existed_company original_new_method = CompanyRegister::Client.method(:new)