Skip to content
This repository has been archived by the owner on Aug 29, 2018. It is now read-only.

Commit

Permalink
Switch to LIST_DOMAINS_BY_OWNER
Browse files Browse the repository at this point in the history
  • Loading branch information
smarterclayton committed Jul 23, 2013
1 parent c92a188 commit 1dbda98
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rhc/rest/client.rb
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions spec/rhc/rest_client_spec.rb
Expand Up @@ -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' }
Expand Down

0 comments on commit 1dbda98

Please sign in to comment.