Skip to content

Commit 5f87e3b

Browse files
committed
add test for PATCH
1 parent 4dd08b6 commit 5f87e3b

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

app/controllers/v3/service_instances_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ def raise_if_invalid_service_plan!(service_instance, message)
415415
service_plan = ServicePlan.first(guid: message.service_plan_guid)
416416
unprocessable_service_plan! unless service_plan_valid?(service_plan)
417417
unavailable_service_plan!(service_plan) unless service_plan_active?(service_plan)
418-
service_plan_not_visible_in_space!(service_plan, space) unless service_plan_exists_in_space?(service_plan, service_instance.space)
418+
service_plan_not_visible_in_space!(service_plan, service_instance.space) unless service_plan_exists_in_space?(service_plan, service_instance.space)
419419
invalid_service_plan_relation! unless service_plan.service == service_instance.service
420420
end
421421

@@ -442,7 +442,7 @@ def unavailable_service_plan!(service_plan)
442442

443443
def service_plan_not_visible_in_space!(service_plan, space)
444444
unprocessable!('Invalid service plan. This could be due to a space-scoped broker which is offering the service plan ' \
445-
"'#{service_plan.name}' with guid '#{service_plan.guid} in another space or that the plan " \
445+
"'#{service_plan.name}' with guid '#{service_plan.guid}' in another space or that the plan " \
446446
'is not enabled in this organization. Ensure that the service plan is visible in your current space ' \
447447
"'#{space.name}' with guid '#{space.guid}'.")
448448
end

spec/request/service_instances_spec.rb

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,7 @@ def check_filtered_instances(*instances)
12611261
expect(parsed_response['errors']).to include(
12621262
include({
12631263
'detail' => 'Invalid service plan. This could be due to a space-scoped broker which is offering the service plan ' \
1264-
"'#{service_plan.name}' with guid '#{service_plan.guid} in another space or that the plan " \
1264+
"'#{service_plan.name}' with guid '#{service_plan.guid}' in another space or that the plan " \
12651265
'is not enabled in this organization. Ensure that the service plan is visible in your current space ' \
12661266
"'#{space.name}' with guid '#{space.guid}'.",
12671267
'title' => 'CF-UnprocessableEntity',
@@ -2409,6 +2409,26 @@ def check_filtered_instances(*instances)
24092409
end
24102410
end
24112411

2412+
context 'not enabled in that org' do
2413+
let(:service_plan) { VCAP::CloudController::ServicePlan.make(public: false, active: true) }
2414+
let(:service_plan_guid) { service_plan.guid }
2415+
2416+
it 'fails saying the plan is invalid' do
2417+
api_call.call(admin_headers)
2418+
expect(last_response).to have_status_code(422)
2419+
expect(parsed_response['errors']).to include(
2420+
include({
2421+
'detail' => 'Invalid service plan. This could be due to a space-scoped broker which is offering the service plan ' \
2422+
"'#{service_plan.name}' with guid '#{service_plan.guid}' in another space or that the plan " \
2423+
'is not enabled in this organization. Ensure that the service plan is visible in your current space ' \
2424+
"'#{space.name}' with guid '#{space.guid}'.",
2425+
'title' => 'CF-UnprocessableEntity',
2426+
'code' => 10_008
2427+
})
2428+
)
2429+
end
2430+
end
2431+
24122432
context 'not available' do
24132433
let(:service_plan) { VCAP::CloudController::ServicePlan.make(public: true, active: false) }
24142434
let(:service_plan_guid) { service_plan.guid }

0 commit comments

Comments
 (0)