mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 19:20:37 +02:00
parent
bb108efedd
commit
fa52001be6
141 changed files with 1388 additions and 1664 deletions
|
@ -15,18 +15,18 @@ class ApiV1AuctionDetailsTest < ActionDispatch::IntegrationTest
|
|||
assert_equal 'auction.test', @auction.domain
|
||||
assert_equal Auction.statuses[:no_bids], @auction.status
|
||||
|
||||
get api_v1_auction_path(@auction.uuid), nil, 'Content-Type' => Mime::JSON.to_s
|
||||
get api_v1_auction_path(@auction.uuid), as: :json
|
||||
|
||||
assert_response :ok
|
||||
assert_equal ({ 'id' => '1b3ee442-e8fe-4922-9492-8fcb9dccc69c',
|
||||
'domain' => 'auction.test',
|
||||
'status' => Auction.statuses[:no_bids] }), ActiveSupport::JSON
|
||||
.decode(response.body)
|
||||
.decode(response.body)
|
||||
end
|
||||
|
||||
def test_auction_not_found
|
||||
assert_raises ActiveRecord::RecordNotFound do
|
||||
get api_v1_auction_path('non-existing-uuid'), nil, 'Content-Type' => Mime::JSON.to_s
|
||||
get api_v1_auction_path('non-existing-uuid'), as: :json
|
||||
end
|
||||
end
|
||||
end
|
|
@ -10,19 +10,19 @@ class ApiV1AuctionListTest < ActionDispatch::IntegrationTest
|
|||
domain: 'auction.test',
|
||||
status: Auction.statuses[:started])
|
||||
|
||||
get api_v1_auctions_path, nil, 'Content-Type' => Mime::JSON.to_s
|
||||
get api_v1_auctions_path, as: :json
|
||||
|
||||
assert_response :ok
|
||||
assert_equal ([{ 'id' => '1b3ee442-e8fe-4922-9492-8fcb9dccc69c',
|
||||
'domain' => 'auction.test',
|
||||
'status' => Auction.statuses[:started] }]), ActiveSupport::JSON
|
||||
.decode(response.body)
|
||||
.decode(response.body)
|
||||
end
|
||||
|
||||
def test_does_not_return_finished_auctions
|
||||
@auction.update!(domain: 'auction.test', status: Auction.statuses[:awaiting_payment])
|
||||
|
||||
get api_v1_auctions_path, nil, 'Content-Type' => Mime::JSON.to_s
|
||||
get api_v1_auctions_path, as: :json
|
||||
|
||||
assert_response :ok
|
||||
assert_empty ActiveSupport::JSON.decode(response.body)
|
||||
|
|
|
@ -20,47 +20,53 @@ class ApiV1AuctionUpdateTest < ActionDispatch::IntegrationTest
|
|||
assert_equal '1b3ee442-e8fe-4922-9492-8fcb9dccc69c', @auction.uuid
|
||||
assert_equal 'auction.test', @auction.domain
|
||||
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:awaiting_payment] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_auction_path(@auction.uuid),
|
||||
params: { status: Auction.statuses[:awaiting_payment] },
|
||||
as: :json
|
||||
|
||||
assert_response :ok
|
||||
assert_equal ({ 'id' => '1b3ee442-e8fe-4922-9492-8fcb9dccc69c',
|
||||
'domain' => 'auction.test',
|
||||
'status' => Auction.statuses[:awaiting_payment] }), ActiveSupport::JSON
|
||||
.decode(response.body)
|
||||
.decode(response.body)
|
||||
end
|
||||
|
||||
def test_marks_as_awaiting_payment
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:awaiting_payment] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_auction_path(@auction.uuid),
|
||||
params: { status: Auction.statuses[:awaiting_payment] },
|
||||
as: :json
|
||||
@auction.reload
|
||||
assert @auction.awaiting_payment?
|
||||
end
|
||||
|
||||
def test_marks_as_no_bids
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:no_bids] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_auction_path(@auction.uuid),
|
||||
params: { status: Auction.statuses[:no_bids] },
|
||||
as: :json
|
||||
@auction.reload
|
||||
assert @auction.no_bids?
|
||||
end
|
||||
|
||||
def test_marks_as_payment_received
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:payment_received] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_auction_path(@auction.uuid),
|
||||
params: { status: Auction.statuses[:payment_received] },
|
||||
as: :json
|
||||
@auction.reload
|
||||
assert @auction.payment_received?
|
||||
end
|
||||
|
||||
def test_marks_as_payment_not_received
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:payment_not_received] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_auction_path(@auction.uuid),
|
||||
params: { status: Auction.statuses[:payment_not_received] },
|
||||
as: :json
|
||||
@auction.reload
|
||||
assert @auction.payment_not_received?
|
||||
end
|
||||
|
||||
def test_marks_as_domain_not_registered
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:domain_not_registered] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_auction_path(@auction.uuid),
|
||||
params: { status: Auction.statuses[:domain_not_registered] },
|
||||
as: :json
|
||||
@auction.reload
|
||||
assert @auction.domain_not_registered?
|
||||
end
|
||||
|
@ -69,8 +75,9 @@ class ApiV1AuctionUpdateTest < ActionDispatch::IntegrationTest
|
|||
@auction.update!(registration_code: 'auction-001',
|
||||
status: Auction.statuses[:awaiting_payment])
|
||||
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:payment_received] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_auction_path(@auction.uuid),
|
||||
params: { status: Auction.statuses[:payment_received] },
|
||||
as: :json
|
||||
|
||||
response_json = ActiveSupport::JSON.decode(response.body)
|
||||
assert_not_nil response_json['registration_code']
|
||||
|
@ -79,8 +86,9 @@ class ApiV1AuctionUpdateTest < ActionDispatch::IntegrationTest
|
|||
def test_conceals_registration_code_when_payment_is_not_received
|
||||
@auction.update!(status: Auction.statuses[:awaiting_payment])
|
||||
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:payment_not_received] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_auction_path(@auction.uuid),
|
||||
params: { status: Auction.statuses[:payment_not_received] },
|
||||
as: :json
|
||||
|
||||
response_json = ActiveSupport::JSON.decode(response.body)
|
||||
assert_nil response_json['registration_code']
|
||||
|
@ -91,8 +99,9 @@ class ApiV1AuctionUpdateTest < ActionDispatch::IntegrationTest
|
|||
assert_equal 'auction.test', @auction.domain
|
||||
@whois_record.update!(updated_at: '2010-07-04')
|
||||
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:payment_received] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_auction_path(@auction.uuid),
|
||||
params: { status: Auction.statuses[:payment_received] },
|
||||
as: :json
|
||||
@whois_record.reload
|
||||
|
||||
assert_equal Time.zone.parse('2010-07-05 10:00'), @whois_record.updated_at
|
||||
|
@ -103,8 +112,9 @@ class ApiV1AuctionUpdateTest < ActionDispatch::IntegrationTest
|
|||
assert_equal 'auction.test', @auction.domain
|
||||
@whois_record.delete
|
||||
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:payment_received] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_auction_path(@auction.uuid),
|
||||
params: { status: Auction.statuses[:payment_received] },
|
||||
as: :json
|
||||
|
||||
new_whois_record = Whois::Record.find_by(name: @auction.domain)
|
||||
assert_equal Time.zone.parse('2010-07-05 10:00'), new_whois_record.updated_at
|
||||
|
@ -114,16 +124,16 @@ class ApiV1AuctionUpdateTest < ActionDispatch::IntegrationTest
|
|||
def test_inaccessible_when_ip_address_is_not_allowed
|
||||
ENV['auction_api_allowed_ips'] = ''
|
||||
|
||||
patch api_v1_auction_path(@auction.uuid), { status: 'any' }.to_json,
|
||||
'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_auction_path(@auction.uuid), params: { status: 'any' }, as: :json
|
||||
|
||||
assert_response :unauthorized
|
||||
end
|
||||
|
||||
def test_auction_not_found
|
||||
assert_raises ActiveRecord::RecordNotFound do
|
||||
patch api_v1_auction_path('non-existing-uuid'), { status: Auction.statuses[:no_bids] }.to_json,
|
||||
'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_auction_path('non-existing-uuid'),
|
||||
params: { status: Auction.statuses[:no_bids] },
|
||||
as: :json
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,8 +14,8 @@ class RegistrantApiV1ContactDetailsTest < ActionDispatch::IntegrationTest
|
|||
end
|
||||
|
||||
def test_returns_contact_details
|
||||
get api_v1_registrant_contact_path(@contact.uuid), nil, 'HTTP_AUTHORIZATION' => auth_token,
|
||||
'Content-Type' => Mime::JSON.to_s
|
||||
get api_v1_registrant_contact_path(@contact.uuid), as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
|
||||
assert_response :ok
|
||||
assert_equal ({ id: @contact.uuid,
|
||||
|
@ -43,8 +43,8 @@ class RegistrantApiV1ContactDetailsTest < ActionDispatch::IntegrationTest
|
|||
end
|
||||
|
||||
def test_non_existent_contact
|
||||
get api_v1_registrant_contact_path('non-existent'), nil, 'HTTP_AUTHORIZATION' => auth_token,
|
||||
'Content-Type' => Mime::JSON.to_s
|
||||
get api_v1_registrant_contact_path('non-existent'), as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
|
||||
assert_response :not_found
|
||||
assert_equal({ errors: [base: ['Contact not found']] }, JSON.parse(response.body,
|
||||
|
@ -52,7 +52,7 @@ class RegistrantApiV1ContactDetailsTest < ActionDispatch::IntegrationTest
|
|||
end
|
||||
|
||||
def test_anonymous_user
|
||||
get api_v1_registrant_contact_path(@contact.uuid), nil, 'Content-Type' => Mime::JSON.to_s
|
||||
get api_v1_registrant_contact_path(@contact.uuid)
|
||||
|
||||
assert_response :unauthorized
|
||||
assert_equal({ errors: [base: ['Not authorized']] }, JSON.parse(response.body,
|
||||
|
@ -66,8 +66,8 @@ class RegistrantApiV1ContactDetailsTest < ActionDispatch::IntegrationTest
|
|||
assert_equal 'US-1234', @user.registrant_ident
|
||||
|
||||
CompanyRegister::Client.stub(:new, CompanyRegisterClientStub.new) do
|
||||
get api_v1_registrant_contact_path(@contact.uuid), nil, 'HTTP_AUTHORIZATION' => auth_token,
|
||||
'Content-Type' => Mime::JSON.to_s
|
||||
get api_v1_registrant_contact_path(@contact.uuid), as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
end
|
||||
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
@ -78,8 +78,8 @@ class RegistrantApiV1ContactDetailsTest < ActionDispatch::IntegrationTest
|
|||
assert_equal 'US-1234', @user.registrant_ident
|
||||
@contact.update!(ident: '12345')
|
||||
|
||||
get api_v1_registrant_contact_path(@contact.uuid), nil, 'HTTP_AUTHORIZATION' => auth_token,
|
||||
'Content-Type' => Mime::JSON.to_s
|
||||
get api_v1_registrant_contact_path(@contact.uuid), as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
|
||||
assert_response :not_found
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
|
|
@ -20,8 +20,7 @@ class RegistrantApiV1ContactListTest < ActionDispatch::IntegrationTest
|
|||
assert_equal 'US', @contact.ident_country_code
|
||||
assert_equal 'US-1234', @user.registrant_ident
|
||||
|
||||
get api_v1_registrant_contacts_path, nil, 'HTTP_AUTHORIZATION' => auth_token,
|
||||
'Content-Type' => Mime::JSON.to_s
|
||||
get api_v1_registrant_contacts_path, as: :json, headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
assert_equal 1, response_json.size
|
||||
|
@ -33,8 +32,7 @@ class RegistrantApiV1ContactListTest < ActionDispatch::IntegrationTest
|
|||
@contact = contacts(:acme_ltd)
|
||||
assert_equal 'acme-ltd-001', @contact.code
|
||||
|
||||
get api_v1_registrant_contacts_path, nil, 'HTTP_AUTHORIZATION' => auth_token,
|
||||
'Content-Type' => Mime::JSON.to_s
|
||||
get api_v1_registrant_contacts_path, as: :json, headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
assert_equal 1, response_json.size
|
||||
|
@ -48,8 +46,8 @@ class RegistrantApiV1ContactListTest < ActionDispatch::IntegrationTest
|
|||
assert_equal 'US-1234', @user.registrant_ident
|
||||
|
||||
CompanyRegister::Client.stub(:new, CompanyRegisterClientStub.new) do
|
||||
get api_v1_registrant_contacts_path, nil, 'HTTP_AUTHORIZATION' => auth_token,
|
||||
'Content-Type' => Mime::JSON.to_s
|
||||
get api_v1_registrant_contacts_path, as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
end
|
||||
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
|
|
@ -21,12 +21,11 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
|
|||
email: 'john@shop.test',
|
||||
phone: '+111.1')
|
||||
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), { name: 'William',
|
||||
email: 'william@shop.test',
|
||||
phone: '+222.2' }.to_json,
|
||||
'HTTP_AUTHORIZATION' => auth_token,
|
||||
'Accept' => Mime::JSON,
|
||||
'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), params: { name: 'William',
|
||||
email: 'william@shop.test',
|
||||
phone: '+222.2' },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
assert_response :ok
|
||||
@contact.reload
|
||||
|
||||
|
@ -37,10 +36,9 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
|
|||
|
||||
def test_notify_registrar
|
||||
assert_difference -> { @contact.registrar.notifications.count } do
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), { name: 'new name' }.to_json,
|
||||
'HTTP_AUTHORIZATION' => auth_token,
|
||||
'Accept' => Mime::JSON,
|
||||
'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), params: { name: 'new name' },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
end
|
||||
notification = @contact.registrar.notifications.last
|
||||
assert_equal 'Contact john-001 has been updated by registrant', notification.text
|
||||
|
@ -50,10 +48,9 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
|
|||
@contact.update!(fax: '+666.6')
|
||||
ENV['fax_enabled'] = 'true'
|
||||
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), { fax: '+777.7' }.to_json,
|
||||
'HTTP_AUTHORIZATION' => auth_token,
|
||||
'Accept' => Mime::JSON,
|
||||
'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), params: { fax: '+777.7' },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
|
||||
assert_response :ok
|
||||
@contact.reload
|
||||
|
@ -63,10 +60,9 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
|
|||
def test_fax_cannot_be_updated_when_disabled
|
||||
ENV['fax_enabled'] = 'false'
|
||||
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), { fax: '+823.7' }.to_json,
|
||||
'HTTP_AUTHORIZATION' => auth_token,
|
||||
'Accept' => Mime::JSON,
|
||||
'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), params: { fax: '+823.7' },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
|
||||
assert_response :bad_request
|
||||
@contact.reload
|
||||
|
@ -80,14 +76,13 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
|
|||
def test_update_address_when_enabled
|
||||
Setting.address_processing = true
|
||||
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), { address: { city: 'new city',
|
||||
street: 'new street',
|
||||
zip: '92837',
|
||||
country_code: 'RU',
|
||||
state: 'new state' } }.to_json,
|
||||
'HTTP_AUTHORIZATION' => auth_token,
|
||||
'Accept' => Mime::JSON,
|
||||
'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), params: { address: { city: 'new city',
|
||||
street: 'new street',
|
||||
zip: '92837',
|
||||
country_code: 'RU',
|
||||
state: 'new state' } },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
|
||||
assert_response :ok
|
||||
@contact.reload
|
||||
|
@ -99,10 +94,9 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
|
|||
@contact.update!(street: 'any', zip: 'any', city: 'any', state: 'any', country_code: 'US')
|
||||
Setting.address_processing = true
|
||||
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), { name: 'any' }.to_json,
|
||||
'HTTP_AUTHORIZATION' => auth_token,
|
||||
'Accept' => Mime::JSON,
|
||||
'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), params: { name: 'any' },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
|
||||
assert_response :ok
|
||||
end
|
||||
|
@ -111,11 +105,10 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
|
|||
@contact.update!(street: 'old street')
|
||||
Setting.address_processing = false
|
||||
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), { address: { street: 'new street' } }
|
||||
.to_json,
|
||||
'HTTP_AUTHORIZATION' => auth_token,
|
||||
'Accept' => Mime::JSON,
|
||||
'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_registrant_contact_path(@contact.uuid),
|
||||
params: { address: { street: 'new street' } },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
@contact.reload
|
||||
|
||||
assert_response :bad_request
|
||||
|
@ -130,10 +123,10 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
|
|||
@contact.update!(ident_type: Contact::PRIV,
|
||||
disclosed_attributes: %w[])
|
||||
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), { disclosed_attributes: %w[name] }.to_json,
|
||||
'HTTP_AUTHORIZATION' => auth_token,
|
||||
'Accept' => Mime::JSON,
|
||||
'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_registrant_contact_path(@contact.uuid),
|
||||
params: { disclosed_attributes: %w[name] },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
@contact.reload
|
||||
|
||||
assert_response :ok
|
||||
|
@ -143,10 +136,10 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
|
|||
def test_conceal_private_persons_data
|
||||
@contact.update!(ident_type: Contact::PRIV, disclosed_attributes: %w[name])
|
||||
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), { disclosed_attributes: [] }.to_json,
|
||||
{ 'HTTP_AUTHORIZATION' => auth_token,
|
||||
'Accept' => Mime::JSON,
|
||||
'Content-Type' => Mime::JSON.to_s }
|
||||
patch api_v1_registrant_contact_path(@contact.uuid),
|
||||
params: { disclosed_attributes: [] },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
|
||||
@contact.reload
|
||||
|
||||
|
@ -166,11 +159,10 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
|
|||
assert_equal 'US-1234', @user.registrant_ident
|
||||
|
||||
assert_no_changes -> { @contact.disclosed_attributes } do
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), { disclosed_attributes: %w[name] }
|
||||
.to_json,
|
||||
'HTTP_AUTHORIZATION' => auth_token,
|
||||
'Accept' => Mime::JSON,
|
||||
'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_registrant_contact_path(@contact.uuid),
|
||||
params: { disclosed_attributes: %w[name] },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
@contact.reload
|
||||
end
|
||||
assert_response :bad_request
|
||||
|
@ -182,10 +174,9 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
|
|||
end
|
||||
|
||||
def test_return_contact_details
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), { name: 'new name' }.to_json,
|
||||
'HTTP_AUTHORIZATION' => auth_token,
|
||||
'Accept' => Mime::JSON,
|
||||
'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), params: { name: 'new name' },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
assert_equal ({ id: @contact.uuid,
|
||||
name: 'new name',
|
||||
code: @contact.code,
|
||||
|
@ -211,10 +202,9 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
|
|||
end
|
||||
|
||||
def test_errors
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), { phone: 'invalid' }.to_json,
|
||||
'HTTP_AUTHORIZATION' => auth_token,
|
||||
'Accept' => Mime::JSON,
|
||||
'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), params: { phone: 'invalid' },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
|
||||
assert_response :bad_request
|
||||
assert_equal ({ errors: { phone: ['Phone nr is invalid'] } }), JSON.parse(response.body,
|
||||
|
@ -225,10 +215,9 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
|
|||
assert_equal 'US-1234', @user.registrant_ident
|
||||
@contact.update!(ident: '12345')
|
||||
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), { name: 'new name' }.to_json,
|
||||
'HTTP_AUTHORIZATION' => auth_token,
|
||||
'Accept' => Mime::JSON,
|
||||
'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), params: { name: 'new name' },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
@contact.reload
|
||||
|
||||
assert_response :not_found
|
||||
|
@ -236,7 +225,8 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
|
|||
end
|
||||
|
||||
def test_non_existent_contact
|
||||
patch api_v1_registrant_contact_path('non-existent'), nil, 'HTTP_AUTHORIZATION' => auth_token
|
||||
patch api_v1_registrant_contact_path('non-existent'),
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
assert_response :not_found
|
||||
assert_equal ({ errors: [{ base: ['Not found'] }] }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue