Module: CcApiStub::Organizations

Extended by:
Helper
Defined in:
lib/cc_api_stub/organizations.rb

Class Method Summary collapse

Methods included from Helper

fail_request, fail_to_load, fail_to_load_many, fail_to_update, fail_with_error, find_fixture, fixture_prefix, host, host=, load_fixtures, object_class, object_name, response, response, stub_delete, stub_get, stub_post, stub_put, stub_request, succeed_to_create, succeed_to_delete, succeed_to_load, succeed_to_load_empty, succeed_to_load_many, succeed_to_update

Class Method Details

.domain_fixture_hashObject



39
40
41
# 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_fixtureObject



35
36
37
# 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) ⇒ Object



15
16
17
# 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_hashObject



63
64
65
# 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_fixtureObject



59
60
61
# File 'lib/cc_api_stub/organizations.rb', line 59

def spaces_fixture
  Helper.load_fixtures("fake_cc_organization_spaces")
end

.succeed_to_createObject



6
7
8
9
# 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_domainsObject



43
44
45
# 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_spacesObject



67
68
69
# 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 = {}) ⇒ Object



19
20
21
22
23
# 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_usersObject



55
56
57
# 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(name) ⇒ Object



25
26
27
28
# File 'lib/cc_api_stub/organizations.rb', line 25

def succeed_to_search(name)
  response_body = Helper.load_fixtures("fake_cc_organization_search")
  stub_get(%r{/v2/organizations\?inline-relations-depth=1&q=name:#{name}$}, {}, response(200, response_body))
end

.succeed_to_search_noneObject



30
31
32
33
# 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_fixtureObject



11
12
13
# File 'lib/cc_api_stub/organizations.rb', line 11

def summary_fixture
  Helper.load_fixtures("fake_cc_organization_summary")
end

.user_fixture_hashObject



51
52
53
# 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_fixtureObject



47
48
49
# File 'lib/cc_api_stub/organizations.rb', line 47

def users_fixture
  Helper.load_fixtures("fake_cc_organization_users")
end