Merge pull request #2723 from internetee/company-validator-during-creation

feat: restore company validation for Estonian organizations
This commit is contained in:
Timo Võhmar 2025-02-12 10:33:28 +02:00 committed by GitHub
commit 38dc5466e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 183 additions and 94 deletions

View file

@ -188,39 +188,38 @@ 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]
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)

View file

@ -4,6 +4,7 @@ class BaseTest < ActiveSupport::TestCase
setup do
@domain = domains(:shop)
@domain_airport = domains(:airport)
travel_to Time.zone.parse('2010-07-05 00:30:00')
end
def test_hold_domains_force_delete_email
@ -58,21 +59,6 @@ class BaseTest < ActiveSupport::TestCase
Setting.redemption_grace_period.days).to_date
end
def test_should_send_poll_message_about_45_days_to_registrar
refute @domain_airport.force_delete_scheduled?
@domain_airport.update!(valid_to: Time.zone.now + 3.years - 1.month - 4.days)
@domain_airport.reload
prepare_contact
contact = @domain_airport.admin_contacts.first
assert_difference -> { @domain_airport.registrar.notifications.count } do
Domains::ForceDeleteEmail::Base.run(email: contact.email)
end
@domain_airport.reload
end
private
def prepare_contact

View file

@ -184,7 +184,8 @@ class CompanyRegisterStatusJobTest < ActiveSupport::TestCase
ident: @registrant_acme.ident,
domain_name: @registrant_acme.registrant_domains.first.name,
outzone_date: @registrant_acme.registrant_domains.first.outzone_date,
purge_date: @registrant_acme.registrant_domains.first.purge_date)
purge_date: @registrant_acme.registrant_domains.first.purge_date,
notes: "Contact has status deleted")
assert_equal @registrant_acme.registrant_domains.first.registrar.notifications.last.text, template
CompanyRegister::Client.define_singleton_method(:new, original_new_method)
@ -303,7 +304,7 @@ class CompanyRegisterStatusJobTest < ActiveSupport::TestCase
@registrant_acme.reload
assert @registrant_acme.registrant_domains.all?(&:force_delete_scheduled?)
assert_not @registrant_acme.registrant_domains.all?(&:force_delete_scheduled?)
assert_equal Contact::BANKRUPT, @registrant_acme.company_register_status
CompanyRegister::Client.define_singleton_method(:new, original_new_method)

View file

@ -532,7 +532,7 @@ class ForceDeleteTest < ActionMailer::TestCase
assert_equal Date.parse('2010-09-19'), @domain.force_delete_date.to_date
assert_equal Date.parse('2010-08-05'), @domain.force_delete_start.to_date
assert_enqueued_jobs 8
assert_enqueued_jobs 6
end
def prepare_bounced_email_address(email)