mirror of
https://github.com/internetee/registry.git
synced 2025-07-20 17:55:55 +02:00
Make returned API errors more consistent
This commit is contained in:
parent
de9b1517b0
commit
0798001725
2 changed files with 4 additions and 4 deletions
|
@ -31,7 +31,7 @@ module Api
|
||||||
if @contact
|
if @contact
|
||||||
render json: @contact
|
render json: @contact
|
||||||
else
|
else
|
||||||
render json: { errors: ['Contact not found'] }, status: :not_found
|
render json: { errors: [{ base: ['Contact not found'] }] }, status: :not_found
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ class RegistrantApiContactsTest < ActionDispatch::IntegrationTest
|
||||||
assert_equal(401, response.status)
|
assert_equal(401, response.status)
|
||||||
json_body = JSON.parse(response.body, symbolize_names: true)
|
json_body = JSON.parse(response.body, symbolize_names: true)
|
||||||
|
|
||||||
assert_equal({ errors: ['Not authorized'] }, json_body)
|
assert_equal({ errors: [base: ['Not authorized']] }, json_body)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_details_returns_401_without_authorization
|
def test_details_returns_401_without_authorization
|
||||||
|
@ -58,7 +58,7 @@ class RegistrantApiContactsTest < ActionDispatch::IntegrationTest
|
||||||
assert_equal(401, response.status)
|
assert_equal(401, response.status)
|
||||||
json_body = JSON.parse(response.body, symbolize_names: true)
|
json_body = JSON.parse(response.body, symbolize_names: true)
|
||||||
|
|
||||||
assert_equal({ errors: ['Not authorized'] }, json_body)
|
assert_equal({ errors: [base: ['Not authorized']] }, json_body)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_details_returns_404_for_non_existent_contact
|
def test_details_returns_404_for_non_existent_contact
|
||||||
|
@ -66,7 +66,7 @@ class RegistrantApiContactsTest < ActionDispatch::IntegrationTest
|
||||||
assert_equal(404, response.status)
|
assert_equal(404, response.status)
|
||||||
json_body = JSON.parse(response.body, symbolize_names: true)
|
json_body = JSON.parse(response.body, symbolize_names: true)
|
||||||
|
|
||||||
assert_equal({ errors: ['Contact not found'] }, json_body)
|
assert_equal({ errors: [base: ['Contact not found']] }, json_body)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue