Class: RHC::Rest::Mock::MockRestDomain
- Includes:
- Helpers
- Defined in:
- lib/rhc/rest/mock.rb
Instance Method Summary collapse
- #add_application(name, type = nil, scale = nil, gear_profile = 'default', git_url = nil) ⇒ Object
- #add_member(member) ⇒ Object
- #applications(*args) ⇒ Object
- #destroy(force = false) ⇒ Object
- #init_members ⇒ Object
-
#initialize(client, id) ⇒ MockRestDomain
constructor
A new instance of MockRestDomain.
- #rename(id) ⇒ Object
Methods included from Helpers
#challenge, #credentials_for, #define_exceptional_test_on_wizard, #empty_domains, #empty_keys, #empty_response_list, #example_allows_gear_sizes?, #example_allows_members?, #expect_authorization, #mock_alias_links, #mock_alias_response, #mock_api_with_authorizations, #mock_app_links, #mock_cart_links, #mock_cartridge_response, #mock_client_links, #mock_date_1, #mock_domain_links, #mock_gear_groups_response, #mock_href, #mock_key_links, #mock_pass, #mock_real_client_links, #mock_response_links, #mock_team_links, #mock_teams_links, #mock_uri, #mock_user, #mock_user_auth, #mock_user_links, #new_authorization, #new_domain, #simple_carts, #simple_user, #stub_add_authorization, #stub_add_key, #stub_add_key_error, #stub_api, #stub_api_request, #stub_api_v12, #stub_application_cartridges, #stub_authorizations, #stub_create_domain, #stub_delete_authorization, #stub_delete_authorizations, #stub_mock_ssh_keys, #stub_no_domains, #stub_no_keys, #stub_one_application, #stub_one_domain, #stub_one_key, #stub_relative_application, #stub_simple_carts, #stub_update_key, #stub_user
Methods inherited from Domain
#configure, #id, #id_and_name, #name, #supports_add_application_with_env_vars?
Methods included from RHC::Rest::Membership
#compact_members, #default_member_role, #delete_members, included, #leave, #members, #owner, #supports_members?, #supports_update_members?, #update_members
Methods inherited from Base
#add_message, #has_param?, #link_href, #links, #rest_method, #supports?
Methods included from AttributesClass
Methods included from Attributes
#attribute, #attributes, #attributes=, #clear_attribute
Constructor Details
#initialize(client, id) ⇒ MockRestDomain
Returns a new instance of MockRestDomain.
726 727 728 729 730 731 |
# File 'lib/rhc/rest/mock.rb', line 726 def initialize(client, id) super({}, client) @name = id @applications = [] self.attributes = {:links => mock_response_links(mock_domain_links(id))} end |
Instance Method Details
#add_application(name, type = nil, scale = nil, gear_profile = 'default', git_url = nil) ⇒ Object
745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 |
# File 'lib/rhc/rest/mock.rb', line 745 def add_application(name, type=nil, scale=nil, gear_profile='default', git_url=nil) if type.is_a?(Hash) scale = type[:scale] gear_profile = type[:gear_profile] git_url = type[:initial_git_url] = type[:tags] type = Array(type[:cartridges] || type[:cartridge]) end a = MockRestApplication.new(client, name, type, self, scale, gear_profile, git_url) builder = @applications.find{ |app| app.cartridges.map(&:name).any?{ |s| s =~ /^jenkins-[\d\.]+$/ } } a.building_app = builder.name if builder @applications << a a.("Success") a end |
#add_member(member) ⇒ Object
771 772 773 774 775 |
# File 'lib/rhc/rest/mock.rb', line 771 def add_member(member) (@members ||= []) << member (attributes['members'] ||= []) << member.attributes self end |
#applications(*args) ⇒ Object
761 762 763 |
# File 'lib/rhc/rest/mock.rb', line 761 def applications(*args) @applications end |
#destroy(force = false) ⇒ Object
738 739 740 741 742 743 |
# File 'lib/rhc/rest/mock.rb', line 738 def destroy(force=false) raise RHC::Rest::ClientErrorException.new("Applications must be empty.") unless @applications.empty? or force.present? client.domains.delete_if { |d| d.name == @name } @applications = nil end |
#init_members ⇒ Object
765 766 767 768 769 |
# File 'lib/rhc/rest/mock.rb', line 765 def init_members @members ||= [] attributes['members'] ||= [] self end |
#rename(id) ⇒ Object
733 734 735 736 |
# File 'lib/rhc/rest/mock.rb', line 733 def rename(id) @name = id self end |