Fix API method

#661
This commit is contained in:
Artur Beljajev 2018-02-26 10:52:03 +02:00
parent 2db401fd98
commit 0cdbd891cc
2 changed files with 7 additions and 7 deletions

View file

@ -11,7 +11,7 @@ class Registrar
ipv6 = params[:ipv6].split("\r\n")
uri = URI.parse("#{ENV['repp_url']}registrar/nameservers")
request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
request = Net::HTTP::Put.new(uri, 'Content-Type' => 'application/json')
request.body = { data: { type: 'nameserver', id: params[:old_hostname],
attributes: { hostname: params[:new_hostname],
ipv4: ipv4,

View file

@ -12,9 +12,9 @@ class RegistrarNameserverReplacementTest < ActionDispatch::IntegrationTest
attributes: { hostname: 'new-ns.bestnames.test',
ipv4: %w[192.0.2.55 192.0.2.56],
ipv6: %w[2001:db8::55 2001:db8::56] } } }
request_stub = stub_request(:post, /registrar\/nameservers/).with(body: request_body,
headers: { 'Content-type' => 'application/json' },
basic_auth: ['test_goodnames', 'testtest'])
request_stub = stub_request(:put, /registrar\/nameservers/).with(body: request_body,
headers: { 'Content-type' => 'application/json' },
basic_auth: ['test_goodnames', 'testtest'])
.to_return(body: { data: [{
type: 'nameserver',
id: 'new-ns.bestnames.test'
@ -35,9 +35,9 @@ class RegistrarNameserverReplacementTest < ActionDispatch::IntegrationTest
end
def test_fails_gracefully
stub_request(:post, /registrar\/nameservers/).to_return(status: 400,
body: { errors: [{ title: 'epic fail' }] }.to_json,
headers: { 'Content-type' => 'application/json' })
stub_request(:put, /registrar\/nameservers/).to_return(status: 400,
body: { errors: [{ title: 'epic fail' }] }.to_json,
headers: { 'Content-type' => 'application/json' })
visit registrar_domains_url
click_link 'Replace nameserver'