@@ -10,24 +10,18 @@ module VCAP::CloudController
1010 let! ( :organization2 ) { Organization . make name : 'Dungeon World' }
1111 let! ( :organization3 ) { Organization . make name : 'The Sprawl' }
1212 let! ( :inaccessible_organization ) { Organization . make name : 'D&D' }
13- let ( :uaa_client ) { instance_double ( VCAP ::CloudController ::UaaClient ) }
1413
1514 before do
1615 organization1 . add_user ( user )
1716 organization2 . add_user ( user )
1817 organization3 . add_user ( user )
1918 Domain . dataset . destroy # this will clean up the seeded test domains
2019 TestConfig . override ( kubernetes : { } )
21-
22- allow ( CloudController ::DependencyLocator . instance ) . to receive ( :uaa_client ) . and_return ( uaa_client )
23- allow ( uaa_client ) . to receive ( :usernames_for_ids ) . with ( [ user . guid ] ) . and_return (
24- { user . guid => 'Ragnaros' }
25- )
2620 end
2721
2822 describe 'POST /v3/organizations' do
29- let ( :request_body ) {
30- {
23+ it 'creates a new organization with the given name' do
24+ request_body = {
3125 name : 'org1' ,
3226 metadata : {
3327 labels : {
@@ -40,8 +34,7 @@ module VCAP::CloudController
4034 }
4135 }
4236 } . to_json
43- }
44- it 'creates a new organization with the given name' do
37+
4538 expect {
4639 post '/v3/organizations' , request_body , admin_header
4740 } . to change {
@@ -75,12 +68,12 @@ module VCAP::CloudController
7568 end
7669
7770 it 'allows creating a suspended org' do
78- suspended_request_body = {
71+ request_body = {
7972 name : 'suspended-org' ,
8073 suspended : true
8174 } . to_json
8275
83- post '/v3/organizations' , suspended_request_body , admin_header
76+ post '/v3/organizations' , request_body , admin_header
8477 expect ( last_response . status ) . to eq ( 201 )
8578
8679 created_org = Organization . last
@@ -103,58 +96,6 @@ module VCAP::CloudController
10396 }
10497 )
10598 end
106-
107- context 'when "user_org_creation" feature flag is enabled' do
108- before do
109- VCAP ::CloudController ::FeatureFlag . make ( name : 'user_org_creation' , enabled : true )
110- end
111-
112- it 'lets ALL users create orgs' do
113- expect {
114- post '/v3/organizations' , request_body , user_header
115- } . to change {
116- Organization . count
117- } . by 1
118-
119- created_org = Organization . last
120-
121- expect ( last_response . status ) . to eq ( 201 )
122- expect ( parsed_response ) . to be_a_response_like (
123- {
124- 'guid' => created_org . guid ,
125- 'created_at' => iso8601 ,
126- 'updated_at' => iso8601 ,
127- 'name' => 'org1' ,
128- 'links' => {
129- 'self' => { 'href' => "#{ link_prefix } /v3/organizations/#{ created_org . guid } " } ,
130- 'domains' => { 'href' => "http://api2.vcap.me/v3/organizations/#{ created_org . guid } /domains" } ,
131- 'default_domain' => { 'href' => "http://api2.vcap.me/v3/organizations/#{ created_org . guid } /domains/default" } ,
132- 'quota' => { 'href' => "http://api2.vcap.me/v3/organization_quotas/#{ created_org . quota_definition . guid } " }
133- } ,
134- 'relationships' => { 'quota' => { 'data' => { 'guid' => created_org . quota_definition . guid } } } ,
135- 'metadata' => {
136- 'labels' => { 'freaky' => 'friday' } ,
137- 'annotations' => { 'make' => 'subaru' , 'model' => 'xv crosstrek' , 'color' => 'orange' }
138- } ,
139- 'suspended' => false
140- }
141- )
142- end
143- it 'gives the user all org roles associated with the new org' do
144- expect {
145- post '/v3/organizations' , request_body , user_header
146- } . to change {
147- Organization . count
148- } . by 1
149-
150- created_org = Organization . last
151- expect ( OrganizationManager . first ( organization_id : created_org . id , user_id : user . id ) ) . to be_present
152- expect ( OrganizationBillingManager . first ( organization_id : created_org . id , user_id : user . id ) ) . to be_present
153- expect ( OrganizationAuditor . first ( organization_id : created_org . id , user_id : user . id ) ) . to be_present
154- expect ( OrganizationUser . first ( organization_id : created_org . id , user_id : user . id ) ) . to be_present
155- expect ( last_response . status ) . to eq ( 201 )
156- end
157- end
15899 end
159100
160101 describe 'GET /v3/organizations' do
0 commit comments