|
398 | 398 | end |
399 | 399 |
|
400 | 400 | describe 'space_guids' do |
401 | | - let!(:service_broker_1) { VCAP::CloudController::ServiceBroker.make(space: space) } |
402 | | - let!(:service_offering_1) { VCAP::CloudController::Service.make(service_broker: service_broker_1) } |
| 401 | + let(:org_1) { VCAP::CloudController::Organization.make } |
| 402 | + let(:org_2) { VCAP::CloudController::Organization.make } |
| 403 | + let!(:org_plan_1) { VCAP::CloudController::ServicePlan.make(public: false) } |
| 404 | + let!(:org_plan_2) { VCAP::CloudController::ServicePlan.make(public: false) } |
| 405 | + let!(:org_offering_1) { org_plan_1.service } |
| 406 | + let!(:org_offering_2) { org_plan_2.service } |
403 | 407 |
|
404 | | - let(:space_2) { VCAP::CloudController::Space.make(organization: org) } |
405 | | - let(:service_broker_2) { VCAP::CloudController::ServiceBroker.make(space: space_2) } |
406 | | - let!(:service_offering_2) { VCAP::CloudController::Service.make(service_broker: service_broker_2) } |
| 408 | + let(:space_1) { VCAP::CloudController::Space.make(organization: org_1) } |
| 409 | + let(:space_2) { VCAP::CloudController::Space.make(organization: org_2) } |
| 410 | + let!(:space_offering_1) { generate_space_scoped_offering(space_1) } |
| 411 | + let!(:space_offering_2) { generate_space_scoped_offering(space_2) } |
407 | 412 |
|
408 | | - let(:space_3) { VCAP::CloudController::Space.make(organization: org) } |
409 | | - let(:service_broker_3) { VCAP::CloudController::ServiceBroker.make(space: space_3) } |
410 | | - let!(:service_offering_3) { VCAP::CloudController::Service.make(service_broker: service_broker_3) } |
| 413 | + let!(:public_offering) { VCAP::CloudController::ServicePlan.make(public: true).service } |
411 | 414 |
|
412 | | - let!(:public_plan) { VCAP::CloudController::ServicePlan.make(public: true) } |
413 | | - let!(:public_service_offering) { public_plan.service } |
| 415 | + before do |
| 416 | + VCAP::CloudController::ServicePlanVisibility.make(service_plan: org_plan_1, organization: org_1) |
| 417 | + VCAP::CloudController::ServicePlanVisibility.make(service_plan: org_plan_2, organization: org_2) |
| 418 | + end |
414 | 419 |
|
415 | | - let!(:space_guids) { [space.guid, space_2.guid] } |
| 420 | + it 'selects on space plans, org plans, and public plans' do |
| 421 | + expect_filtered_service_offerings( |
| 422 | + "space_guids=#{space_1.guid}", |
| 423 | + [org_offering_1, space_offering_1, public_offering] |
| 424 | + ) |
416 | 425 |
|
417 | | - it 'returns the right offerings' do |
418 | 426 | expect_filtered_service_offerings( |
419 | | - "space_guids=#{space_guids.join(',')}", |
420 | | - [service_offering_1, service_offering_2, public_service_offering] |
| 427 | + "space_guids=#{space_1.guid},#{space_2.guid}", |
| 428 | + [org_offering_1, org_offering_2, space_offering_1, space_offering_2, public_offering] |
421 | 429 | ) |
422 | 430 | end |
423 | 431 | end |
424 | 432 |
|
425 | 433 | describe 'organization_guids' do |
426 | | - let!(:service_broker_1) { VCAP::CloudController::ServiceBroker.make(space: space) } |
427 | | - let!(:service_offering_1) { VCAP::CloudController::Service.make(service_broker: service_broker_1) } |
428 | | - |
| 434 | + let(:org_1) { VCAP::CloudController::Organization.make } |
429 | 435 | let(:org_2) { VCAP::CloudController::Organization.make } |
| 436 | + let!(:org_plan_1) { VCAP::CloudController::ServicePlan.make(public: false) } |
| 437 | + let!(:org_plan_2) { VCAP::CloudController::ServicePlan.make(public: false) } |
| 438 | + let!(:org_offering_1) { org_plan_1.service } |
| 439 | + let!(:org_offering_2) { org_plan_2.service } |
| 440 | + |
| 441 | + let(:space_1) { VCAP::CloudController::Space.make(organization: org_1) } |
430 | 442 | let(:space_2) { VCAP::CloudController::Space.make(organization: org_2) } |
431 | | - let(:service_broker_2) { VCAP::CloudController::ServiceBroker.make(space: space_2) } |
432 | | - let!(:service_offering_2) { VCAP::CloudController::Service.make(service_broker: service_broker_2) } |
| 443 | + let!(:space_offering_1) { generate_space_scoped_offering(space_1) } |
| 444 | + let!(:space_offering_2) { generate_space_scoped_offering(space_2) } |
433 | 445 |
|
434 | | - let(:org_3) { VCAP::CloudController::Organization.make } |
435 | | - let(:space_3) { VCAP::CloudController::Space.make(organization: org_3) } |
436 | | - let(:service_broker_3) { VCAP::CloudController::ServiceBroker.make(space: space_3) } |
437 | | - let!(:service_offering_3) { VCAP::CloudController::Service.make(service_broker: service_broker_3) } |
| 446 | + let!(:public_offering) { VCAP::CloudController::ServicePlan.make(public: true).service } |
438 | 447 |
|
439 | | - let!(:public_plan) { VCAP::CloudController::ServicePlan.make(public: true) } |
440 | | - let!(:public_service_offering) { public_plan.service } |
| 448 | + before do |
| 449 | + VCAP::CloudController::ServicePlanVisibility.make(service_plan: org_plan_1, organization: org_1) |
| 450 | + VCAP::CloudController::ServicePlanVisibility.make(service_plan: org_plan_2, organization: org_2) |
| 451 | + end |
441 | 452 |
|
442 | | - let!(:org_guids) { [org.guid, org_2.guid] } |
| 453 | + it 'selects on space plans, org plans, and public plans' do |
| 454 | + expect_filtered_service_offerings( |
| 455 | + "organization_guids=#{org_1.guid}", |
| 456 | + [org_offering_1, space_offering_1, public_offering] |
| 457 | + ) |
443 | 458 |
|
444 | | - it 'returns the right offerings' do |
445 | 459 | expect_filtered_service_offerings( |
446 | | - "organization_guids=#{org_guids.join(',')}", |
447 | | - [service_offering_1, service_offering_2, public_service_offering] |
| 460 | + "organization_guids=#{org_1.guid},#{org_2.guid}", |
| 461 | + [org_offering_1, org_offering_2, space_offering_1, space_offering_2, public_offering] |
448 | 462 | ) |
449 | 463 | end |
450 | 464 | end |
@@ -971,4 +985,9 @@ def expect_filtered_service_offerings(filter, list) |
971 | 985 | expect(parsed_response['resources'][index]['guid']).to eq(service_offering.guid) |
972 | 986 | end |
973 | 987 | end |
| 988 | + |
| 989 | + def generate_space_scoped_offering(space) |
| 990 | + broker = VCAP::CloudController::ServiceBroker.make(space: space) |
| 991 | + VCAP::CloudController::Service.make(service_broker: broker) |
| 992 | + end |
974 | 993 | end |
0 commit comments