mirror of
https://github.com/internetee/registry.git
synced 2025-07-30 06:26:15 +02:00
feat: restore company validation for Estonian organizations
- Re-enable company validation logic for Estonian organization contacts - Update company_register gem to use master branch - Restore and update company validation tests - Add additional check for Estonian country code in validation This change ensures that only registered or liquidated Estonian companies can be used when creating organizational contacts.
This commit is contained in:
parent
45703d4b86
commit
89097bfabe
4 changed files with 42 additions and 42 deletions
4
Gemfile
4
Gemfile
|
@ -68,8 +68,8 @@ gem 'pdfkit'
|
||||||
gem 'redis'
|
gem 'redis'
|
||||||
gem 'sidekiq', '~> 7.0'
|
gem 'sidekiq', '~> 7.0'
|
||||||
|
|
||||||
gem 'company_register', github: 'internetee/company_register',
|
|
||||||
branch: 'issues-with-upcoming-data'
|
gem 'company_register', github: 'internetee/company_register', branch: :master
|
||||||
gem 'domain_name'
|
gem 'domain_name'
|
||||||
gem 'e_invoice', github: 'internetee/e_invoice', branch: :master
|
gem 'e_invoice', github: 'internetee/e_invoice', branch: :master
|
||||||
gem 'haml', '~> 6.0'
|
gem 'haml', '~> 6.0'
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
GIT
|
GIT
|
||||||
remote: https://github.com/internetee/company_register.git
|
remote: https://github.com/internetee/company_register.git
|
||||||
revision: 1e91fec78212d7e549a1c2362c011761a447bbcd
|
revision: 30b2c4d2f0bb882370e174fc965cd9fd02b42951
|
||||||
branch: issues-with-upcoming-data
|
branch: master
|
||||||
specs:
|
specs:
|
||||||
company_register (0.1.0)
|
company_register (0.1.0)
|
||||||
activesupport
|
activesupport
|
||||||
|
@ -304,7 +304,7 @@ GEM
|
||||||
kaminari-core (= 1.2.1)
|
kaminari-core (= 1.2.1)
|
||||||
kaminari-core (1.2.1)
|
kaminari-core (1.2.1)
|
||||||
libxml-ruby (3.2.1)
|
libxml-ruby (3.2.1)
|
||||||
logger (1.6.5)
|
logger (1.6.4)
|
||||||
loofah (2.24.0)
|
loofah (2.24.0)
|
||||||
crass (~> 1.0.2)
|
crass (~> 1.0.2)
|
||||||
nokogiri (>= 1.12.0)
|
nokogiri (>= 1.12.0)
|
||||||
|
|
|
@ -14,7 +14,7 @@ module Actions
|
||||||
maybe_attach_legal_doc
|
maybe_attach_legal_doc
|
||||||
maybe_validate_ident
|
maybe_validate_ident
|
||||||
maybe_change_email
|
maybe_change_email
|
||||||
# maybe_company_is_relevant
|
maybe_company_is_relevant
|
||||||
commit
|
commit
|
||||||
maybe_validate_phone_number
|
maybe_validate_phone_number
|
||||||
maybe_validate_contact
|
maybe_validate_contact
|
||||||
|
@ -79,16 +79,17 @@ 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?
|
||||||
|
return true unless contact.ident_country_code == 'EE'
|
||||||
|
|
||||||
# company_status = contact.return_company_status
|
company_status = contact.return_company_status
|
||||||
|
|
||||||
# return if [Contact::REGISTERED, Contact::LIQUIDATED].include? company_status
|
return true if [Contact::REGISTERED, Contact::LIQUIDATED].include? company_status
|
||||||
# contact.add_epp_error('2003', nil, 'ident', I18n.t('errors.messages.company_not_registered'))
|
contact.add_epp_error('2003', nil, 'ident', I18n.t('errors.messages.company_not_registered'))
|
||||||
|
|
||||||
# @error = true
|
@error = true
|
||||||
# end
|
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)
|
||||||
|
|
|
@ -188,39 +188,38 @@ 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]
|
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