Merge pull request #2741 from internetee/disclose-phone-num-for-org-registrants

Update company_register gem and fix logger dependency
This commit is contained in:
Timo Võhmar 2025-01-31 17:52:57 +02:00 committed by GitHub
commit 268b942042
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 282 additions and 19 deletions

View file

@ -253,4 +253,32 @@ class ReppV1ContactsCreateTest < ActionDispatch::IntegrationTest
CompanyRegister::Client.define_singleton_method(:new, original_new_method)
end
def test_validates_phone_number_after_create
request_body = {
contact: {
name: 'Test Company',
phone: '+372.51111112',
email: 'test@company.com',
ident: {
ident_type: 'org',
ident_country_code: 'EE',
ident: '12345678',
},
},
}
assert_enqueued_with(job: OrgRegistrantPhoneCheckerJob) do
post '/repp/v1/contacts', headers: @auth_headers, params: request_body
end
assert_response :ok
json = JSON.parse(response.body, symbolize_names: true)
assert_equal 1000, json[:code]
assert_equal 'Command completed successfully', json[:message]
contact = Contact.find_by(code: json[:data][:contact][:code])
assert contact.present?
assert_equal '+372.51111112', contact.phone
end
end

View file

@ -142,4 +142,31 @@ class ReppV1ContactsUpdateTest < ActionDispatch::IntegrationTest
ENV["shunter_default_threshold"] = '10000'
ENV["shunter_enabled"] = 'false'
end
def test_validates_phone_number_after_update
@contact.update!(
phone: '+372.555666777',
ident_type: 'org',
ident_country_code: 'EE',
ident: '12345678'
)
request_body = {
contact: {
phone: '+372.123456789'
}
}
assert_enqueued_with(job: OrgRegistrantPhoneCheckerJob) do
put "/repp/v1/contacts/#{@contact.code}", headers: @auth_headers, params: request_body
end
assert_response :ok
json = JSON.parse(response.body, symbolize_names: true)
assert_equal 1000, json[:code]
assert_equal 'Command completed successfully', json[:message]
@contact.reload
assert_equal '+372.123456789', @contact.phone
end
end