mirror of
https://github.com/internetee/registry.git
synced 2025-07-20 17:55:55 +02:00
Improve readability
This commit is contained in:
parent
ca1c9614e5
commit
1bbf7e73d0
2 changed files with 10 additions and 6 deletions
|
@ -53,7 +53,8 @@ module Api
|
||||||
|
|
||||||
if disclosed_attributes
|
if disclosed_attributes
|
||||||
if contact.org?
|
if contact.org?
|
||||||
error_msg = "Legal person's data cannot be concealed. Please remove this parameter."
|
error_msg = "Legal person's data is visible by default and cannot be concealed." \
|
||||||
|
' Please remove this parameter.'
|
||||||
render json: { errors: [{ disclosed_attributes: [error_msg] }] }, status: :bad_request
|
render json: { errors: [{ disclosed_attributes: [error_msg] }] }, status: :bad_request
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
|
@ -159,19 +159,22 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
|
||||||
assert_empty @contact.disclosed_attributes
|
assert_empty @contact.disclosed_attributes
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_legal_persons_data_cannot_be_concealed
|
def test_legal_persons_disclosed_attributes_cannot_be_changed
|
||||||
@contact.update!(ident_type: Contact::ORG,
|
@contact.update!(ident_type: Contact::ORG,
|
||||||
disclosed_attributes: %w[])
|
disclosed_attributes: %w[])
|
||||||
|
|
||||||
assert_no_changes -> { @contact.disclosed_attributes } do
|
assert_no_changes -> { @contact.disclosed_attributes } do
|
||||||
patch api_v1_registrant_contact_path(@contact.uuid), { disclosed_attributes: %w[name] }.to_json,
|
patch api_v1_registrant_contact_path(@contact.uuid), { disclosed_attributes: %w[name] }
|
||||||
|
.to_json,
|
||||||
'HTTP_AUTHORIZATION' => auth_token,
|
'HTTP_AUTHORIZATION' => auth_token,
|
||||||
'Accept' => Mime::JSON,
|
'Accept' => Mime::JSON,
|
||||||
'Content-Type' => Mime::JSON.to_s
|
'Content-Type' => Mime::JSON.to_s
|
||||||
@contact.reload
|
@contact.reload
|
||||||
end
|
end
|
||||||
assert_response :bad_request
|
assert_response :bad_request
|
||||||
error_msg = "Legal person's data cannot be concealed. Please remove this parameter."
|
|
||||||
|
error_msg = "Legal person's data is visible by default and cannot be concealed." \
|
||||||
|
' Please remove this parameter.'
|
||||||
assert_equal ({ errors: [{ disclosed_attributes: [error_msg] }] }),
|
assert_equal ({ errors: [{ disclosed_attributes: [error_msg] }] }),
|
||||||
JSON.parse(response.body, symbolize_names: true)
|
JSON.parse(response.body, symbolize_names: true)
|
||||||
end
|
end
|
||||||
|
@ -220,14 +223,14 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
|
||||||
@current_user.update!(registrant_ident: 'US-1234')
|
@current_user.update!(registrant_ident: 'US-1234')
|
||||||
@contact.update!(ident: '12345')
|
@contact.update!(ident: '12345')
|
||||||
|
|
||||||
patch api_v1_registrant_contact_path(@contact.uuid), { name: 'any' }.to_json,
|
patch api_v1_registrant_contact_path(@contact.uuid), { name: 'new name' }.to_json,
|
||||||
'HTTP_AUTHORIZATION' => auth_token,
|
'HTTP_AUTHORIZATION' => auth_token,
|
||||||
'Accept' => Mime::JSON,
|
'Accept' => Mime::JSON,
|
||||||
'Content-Type' => Mime::JSON.to_s
|
'Content-Type' => Mime::JSON.to_s
|
||||||
@contact.reload
|
@contact.reload
|
||||||
|
|
||||||
assert_response :not_found
|
assert_response :not_found
|
||||||
assert_not_equal 'any', @contact.name
|
assert_not_equal 'new name', @contact.name
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_non_existent_contact
|
def test_non_existent_contact
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue