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") ipv6 = params[:ipv6].split("\r\n")
uri = URI.parse("#{ENV['repp_url']}registrar/nameservers") 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], request.body = { data: { type: 'nameserver', id: params[:old_hostname],
attributes: { hostname: params[:new_hostname], attributes: { hostname: params[:new_hostname],
ipv4: ipv4, ipv4: ipv4,

View file

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