mirror of
https://github.com/internetee/registry.git
synced 2025-06-04 19:57:29 +02:00
Add test for error in business registry
This commit is contained in:
parent
4cc0669286
commit
256d2b7de4
2 changed files with 12 additions and 1 deletions
|
@ -48,7 +48,7 @@ module Api
|
||||||
@contacts_pool = Contact.where(id: available_contacts_ids)
|
@contacts_pool = Contact.where(id: available_contacts_ids)
|
||||||
rescue Soap::Arireg::NotAvailableError => error
|
rescue Soap::Arireg::NotAvailableError => error
|
||||||
Rails.logger.fatal("[EXCEPTION] #{error}")
|
Rails.logger.fatal("[EXCEPTION] #{error}")
|
||||||
render json: { errors: [{ base: ["Business Registry Not Available"] }] },
|
render json: { errors: [{ base: ["Business Registry not available"] }] },
|
||||||
status: :service_unavailable and return
|
status: :service_unavailable and return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -50,6 +50,17 @@ class RegistrantApiContactsTest < ApplicationIntegrationTest
|
||||||
assert_equal('william@inbox.test', contact[:email])
|
assert_equal('william@inbox.test', contact[:email])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_root_returns_503_when_business_registry_is_not_available
|
||||||
|
raise_not_available = -> (a, b) { raise Soap::Arireg::NotAvailableError.new({}) }
|
||||||
|
BusinessRegistryCache.stub :fetch_by_ident_and_cc, raise_not_available do
|
||||||
|
get '/api/v1/registrant/contacts', {}, @auth_headers
|
||||||
|
|
||||||
|
assert_equal(503, response.status)
|
||||||
|
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||||
|
assert_equal({ errors: [base: ['Business Registry not available']] }, response_json)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_get_contact_details_by_uuid_returns_404_for_non_existent_contact
|
def test_get_contact_details_by_uuid_returns_404_for_non_existent_contact
|
||||||
get '/api/v1/registrant/contacts/nonexistent-uuid', {}, @auth_headers
|
get '/api/v1/registrant/contacts/nonexistent-uuid', {}, @auth_headers
|
||||||
assert_equal(404, response.status)
|
assert_equal(404, response.status)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue