Skip to content

Commit

Permalink
Implement RegistrarDelegation.change_domain_delegation
Browse files Browse the repository at this point in the history
  • Loading branch information
jacegu committed Apr 13, 2016
1 parent 9a10b15 commit 8bdf2e6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/dnsimple/client/registrar_delegation.rb
Expand Up @@ -9,6 +9,13 @@ def domain_delegation(account_id, domain_name, options = {})
Dnsimple::Response.new(response, response["data"])
end

def change_domain_delegation(account_id, domain_name, attributes, options = {})
endpoint = Client.versioned("/%s/registrar/domains/%s/delegation" % [account_id, domain_name])
response = client.put(endpoint, attributes, options)

Dnsimple::Response.new(response, response["data"])
end

end
end
end
25 changes: 25 additions & 0 deletions spec/dnsimple/client/registrar_delegation_spec.rb
Expand Up @@ -27,4 +27,29 @@
end
end

describe "#change_domain_delegation" do
let(:account_id) { 1010 }

before do
stub_request(:put, %r{/v2/#{account_id}/registrar/domains/.+/delegation$}).
to_return(read_http_fixture("changeDomainDelegation/success.http"))
end

let(:attributes) { %w(ns1.dnsimple.com ns2.dnsimple.com ns3.dnsimple.com ns4.dnsimple.com) }

it "builds the correct request" do
subject.change_domain_delegation(account_id, domain_name = "example.com", attributes)

expect(WebMock).to have_requested(:put, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_name}/delegation").
with(body: JSON.dump(attributes)).
with(headers: { "Accept" => "application/json" })
end

it "returns the name servers of the domain" do
response = subject.change_domain_delegation(account_id, "example.com", attributes)
expect(response).to be_a(Dnsimple::Response)

expect(response.data).to match_array(%w(ns1.dnsimple.com ns2.dnsimple.com ns3.dnsimple.com ns4.dnsimple.com))
end
end
end

0 comments on commit 8bdf2e6

Please sign in to comment.