From 1dbda984e44b3ef9b450c84bae3d374755766a5c Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Mon, 22 Jul 2013 22:06:58 -0400 Subject: [PATCH] Switch to LIST_DOMAINS_BY_OWNER --- lib/rhc/rest/client.rb | 4 ++-- spec/rhc/rest_client_spec.rb | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/lib/rhc/rest/client.rb b/lib/rhc/rest/client.rb index f9902e50e..ddbd65c6c 100644 --- a/lib/rhc/rest/client.rb +++ b/lib/rhc/rest/client.rb @@ -28,8 +28,8 @@ def domains def owned_domains debug "Getting owned domains" - if link = api.link_href(:LIST_OWNED_DOMAINS) - @owned_domains ||= api.rest_method 'LIST_OWNED_DOMAINS' + if link = api.link_href(:LIST_DOMAINS_BY_OWNER) + @owned_domains ||= api.rest_method 'LIST_DOMAINS_BY_OWNER', :owner => '@self' else domains end diff --git a/spec/rhc/rest_client_spec.rb b/spec/rhc/rest_client_spec.rb index 5198f215c..74bbeccf7 100644 --- a/spec/rhc/rest_client_spec.rb +++ b/spec/rhc/rest_client_spec.rb @@ -273,6 +273,29 @@ module Rest end end + context "when server supports LIST_DOMAINS_BY_OWNER" do + let(:api_links){ client_links.merge!(mock_response_links([['LIST_DOMAINS_BY_OWNER', 'domains', 'get']])) } + before do + stub_api_request(:any, "#{api_links['LIST_DOMAINS_BY_OWNER']['relative']}?owner=@self"). + to_return({ :body => { + :type => 'domains', + :data => [{ + :id => 'mock_domain_0', + :links => mock_response_links(mock_domain_links('mock_domain_0')), + }] + }.to_json, + :status => 200 + }) + end + it "returns owned domains when called" do + match = nil + expect { match = client.owned_domains }.to_not raise_error + match.length.should == 1 + match.first.id.should == 'mock_domain_0' + match.first.class.should == RHC::Rest::Domain + end + end + context "find_application" do let(:mock_domain){ 'mock_domain_0' } let(:mock_app){ 'mock_app' }