module CcApiStub::Organizations

Public Class Methods

domain_fixture_hash() click to toggle source
# File lib/cc_api_stub/organizations.rb, line 39
def domain_fixture_hash
  MultiJson.load(domains_fixture["resources"].first.to_json, :symbolize_keys => true)
end
domains_fixture() click to toggle source
# File lib/cc_api_stub/organizations.rb, line 35
def domains_fixture
  Helper.load_fixtures("fake_cc_organization_domains")
end
fail_to_find(org_id) click to toggle source
# File lib/cc_api_stub/organizations.rb, line 15
def fail_to_find(org_id)
  stub_get(%r{/v2/organizations/#{org_id}}, {}, response(404, {:code => 30003, :description => "The organization could not be found"}))
end
space_fixture_hash() click to toggle source
# File lib/cc_api_stub/organizations.rb, line 63
def space_fixture_hash
  MultiJson.load(spaces_fixture["resources"].first.to_json, :symbolize_keys => true)
end
spaces_fixture() click to toggle source
# File lib/cc_api_stub/organizations.rb, line 59
def spaces_fixture
  Helper.load_fixtures("fake_cc_organization_spaces")
end
succeed_to_create() click to toggle source
# File lib/cc_api_stub/organizations.rb, line 6
def succeed_to_create
  response_body = Helper.load_fixtures("fake_cc_created_organization")
  stub_post(collection_endpoint, {}, response(201, response_body))
end
succeed_to_load_domains() click to toggle source
# File lib/cc_api_stub/organizations.rb, line 43
def succeed_to_load_domains
  stub_get(%r{/v2/organizations/[^/]+/domains\?inline-relations-depth=1}, {}, response(200, domains_fixture))
end
succeed_to_load_spaces() click to toggle source
# File lib/cc_api_stub/organizations.rb, line 67
def succeed_to_load_spaces
  stub_get(%r{/v2/organizations/[^\/]+/spaces\?inline-relations-depth=1}, {}, response(200, spaces_fixture))
end
succeed_to_load_summary(options={}) click to toggle source
# File lib/cc_api_stub/organizations.rb, line 19
def succeed_to_load_summary(options={})
  response_body = summary_fixture
  response_body["spaces"] = [] if options[:no_spaces]
  stub_get(%r{/v2/organizations/[^/]+/summary$}, {}, response(200, response_body))
end
succeed_to_load_users() click to toggle source
# File lib/cc_api_stub/organizations.rb, line 55
def succeed_to_load_users
  stub_get(%r{/v2/organizations/[^\/]+/users\?inline-relations-depth=1}, {}, response(200, users_fixture))
end
succeed_to_search_none() click to toggle source
# File lib/cc_api_stub/organizations.rb, line 30
def succeed_to_search_none
  response_body = Helper.load_fixtures("fake_cc_empty_search")
  stub_get(%r{/v2/organizations\?inline-relations-depth=1&q=name:.*$}, {}, response(200, response_body))
end
summary_fixture() click to toggle source
# File lib/cc_api_stub/organizations.rb, line 11
def summary_fixture
  Helper.load_fixtures("fake_cc_organization_summary")
end
user_fixture_hash() click to toggle source
# File lib/cc_api_stub/organizations.rb, line 51
def user_fixture_hash
  MultiJson.load(users_fixture["resources"].first.to_json, :symbolize_keys => true)
end
users_fixture() click to toggle source
# File lib/cc_api_stub/organizations.rb, line 47
def users_fixture
  Helper.load_fixtures("fake_cc_organization_users")
end

Private Class Methods

collection_endpoint() click to toggle source
# File lib/cc_api_stub/organizations.rb, line 77
def collection_endpoint
  %r{/v2/organizations\/?(\?.+)?$}
end
object_endpoint(id = nil) click to toggle source
# File lib/cc_api_stub/organizations.rb, line 73
def object_endpoint(id = nil)
  %r{/v2/organizations/#{id}[^/]+$}
end