mirror of
https://github.com/internetee/registry.git
synced 2025-08-14 21:43:50 +02:00
Support only JSON
This commit is contained in:
parent
d695d95ad7
commit
8425481091
2 changed files with 15 additions and 10 deletions
|
@ -106,13 +106,15 @@ class Registrant::ContactsController < RegistrantController
|
|||
|
||||
def normalize_address_attributes_for_api(params)
|
||||
normalized = params
|
||||
address_parts = {}
|
||||
|
||||
Contact.address_attribute_names.each do |attr|
|
||||
attr = attr.to_sym
|
||||
normalized["address[#{attr}]"] = params[attr]
|
||||
address_parts[attr] = params[attr]
|
||||
normalized.delete(attr)
|
||||
end
|
||||
|
||||
normalized[:address] = address_parts
|
||||
normalized
|
||||
end
|
||||
|
||||
|
@ -120,7 +122,8 @@ class Registrant::ContactsController < RegistrantController
|
|||
uri = URI.parse("#{ENV['registrant_api_base_url']}/api/v1/registrant/contacts/#{uuid}")
|
||||
request = Net::HTTP::Patch.new(uri)
|
||||
request['Authorization'] = "Bearer #{access_token}"
|
||||
request.form_data = contact_update_api_params
|
||||
request['Content-type'] = 'application/json'
|
||||
request.body = contact_update_api_params.to_json
|
||||
|
||||
Net::HTTP.start(uri.hostname, uri.port, use_ssl: (uri.scheme == 'https')) do |http|
|
||||
http.request(request)
|
||||
|
|
|
@ -34,8 +34,9 @@ class RegistrantAreaContactUpdateTest < ApplicationIntegrationTest
|
|||
def test_update_contact
|
||||
stub_auth_request
|
||||
|
||||
request_body = { name: 'new name', email: 'new@inbox.test', phone: '+666.6' }
|
||||
headers = { 'Authorization' => 'Bearer test-access-token' }
|
||||
request_body = { name: 'new name', email: 'new@inbox.test', phone: '+666.6' }.to_json
|
||||
headers = { 'Content-Type' => Mime::JSON,
|
||||
'Authorization' => 'Bearer test-access-token' }
|
||||
url = "https://api.test/api/v1/registrant/contacts/#{@contact.uuid}"
|
||||
update_request_stub = stub_request(:patch, url).with(body: request_body, headers: headers)
|
||||
.to_return(body: '{}', status: 200)
|
||||
|
@ -104,17 +105,18 @@ class RegistrantAreaContactUpdateTest < ApplicationIntegrationTest
|
|||
Setting.address_processing = true
|
||||
stub_auth_request
|
||||
|
||||
request_body = { email: 'john@inbox.test',
|
||||
name: 'John',
|
||||
request_body = { name: 'John',
|
||||
email: 'john@inbox.test',
|
||||
phone: '+555.555',
|
||||
address: {
|
||||
city: 'new city',
|
||||
street: 'new street',
|
||||
zip: '93742',
|
||||
city: 'new city',
|
||||
country_code: 'AT',
|
||||
state: 'new state',
|
||||
country_code: 'AT'
|
||||
} }
|
||||
headers = { 'Authorization' => 'Bearer test-access-token' }
|
||||
} }.to_json
|
||||
headers = { 'Content-type' => 'application/json',
|
||||
'Authorization' => 'Bearer test-access-token' }
|
||||
url = "https://api.test/api/v1/registrant/contacts/#{@contact.uuid}"
|
||||
update_request_stub = stub_request(:patch, url).with(body: request_body, headers: headers)
|
||||
.to_return(body: '{}', status: 200)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue