mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 03:06:14 +02:00
Wrote test for admin users
This commit is contained in:
parent
3cefaedd4d
commit
0c1c015fc9
4 changed files with 164 additions and 1 deletions
|
@ -4,11 +4,12 @@ require 'auth_token/auth_token_creator'
|
|||
class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@contact = contacts(:john)
|
||||
@contact_org = contacts(:acme_ltd)
|
||||
|
||||
@original_address_processing = Setting.address_processing
|
||||
@original_fax_enabled_setting = ENV['fax_enabled']
|
||||
|
||||
@user = users(:registrant)
|
||||
|
||||
end
|
||||
|
||||
teardown do
|
||||
|
@ -90,6 +91,32 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
|
|||
@contact.address
|
||||
end
|
||||
|
||||
def test_update_address_when_enabled_without_address_params
|
||||
Setting.address_processing = true
|
||||
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), params: { address: { } },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
|
||||
assert_response :bad_request
|
||||
@contact.reload
|
||||
assert_equal Contact::Address.new(nil, nil, nil, nil, nil),
|
||||
@contact.address
|
||||
end
|
||||
|
||||
def test_update_address_when_enabled_without_address_params
|
||||
Setting.address_processing = true
|
||||
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), params: { },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
|
||||
assert_response :bad_request
|
||||
@contact.reload
|
||||
assert_equal Contact::Address.new(nil, nil, nil, nil, nil),
|
||||
@contact.address
|
||||
end
|
||||
|
||||
def test_address_is_optional_when_enabled
|
||||
Setting.address_processing = true
|
||||
@contact.update!(street: 'any', zip: 'any', city: 'any', state: 'any', country_code: 'US')
|
||||
|
@ -211,6 +238,21 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
|
|||
symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_org_disclosed_attributes
|
||||
patch api_v1_registrant_contact_path(@contact_org.uuid), params: { disclosed_attributes: ["some_attr"] },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
|
||||
assert_response :bad_request
|
||||
|
||||
err_msg = "Legal person's data is visible by default and cannot be concealed. Please remove this parameter."
|
||||
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
response_msg = response_json[:errors][0][:disclosed_attributes][0]
|
||||
|
||||
assert_equal err_msg, response_msg
|
||||
end
|
||||
|
||||
def test_unmanaged_contact_cannot_be_updated
|
||||
assert_equal 'US-1234', @user.registrant_ident
|
||||
@contact.update!(ident: '12345')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue