Skip to content

Commit 0eb58ef

Browse files
committed
add error message if plan is inactive
1 parent 48ea714 commit 0eb58ef

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

app/controllers/v3/service_instances_controller.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ def create_user_provided(message)
255255
def create_managed(message, space:)
256256
service_plan = ServicePlan.first(guid: message.service_plan_guid)
257257
unprocessable_service_plan! unless service_plan_valid?(service_plan)
258+
unavailable_service_plan!(service_plan.name) unless service_plan_active?(service_plan)
258259
service_plan_not_visible_in_space! unless service_plan_exists_in_space?(service_plan, space)
259260

260261
action = V3::ServiceInstanceCreateManaged.new(user_audit_info, message.audit_hash)
@@ -400,6 +401,10 @@ def service_plan_valid?(service_plan)
400401
visible_to_current_user?(plan: service_plan)
401402
end
402403

404+
def service_plan_active?(service_plan)
405+
service_plan.active?
406+
end
407+
403408
def service_plan_exists_in_space?(service_plan, space)
404409
service_plan.visible_in_space?(space)
405410
end
@@ -409,6 +414,7 @@ def raise_if_invalid_service_plan!(service_instance, message)
409414

410415
service_plan = ServicePlan.first(guid: message.service_plan_guid)
411416
unprocessable_service_plan! unless service_plan_valid?(service_plan)
417+
unavailable_service_plan!(service_plan.name) unless service_plan_active?(service_plan)
412418
service_plan_not_visible_in_space! unless service_plan_exists_in_space?(service_plan, service_instance.space)
413419
invalid_service_plan_relation! unless service_plan.service == service_instance.service
414420
end
@@ -429,8 +435,12 @@ def unprocessable_service_plan!
429435
unprocessable!('Invalid service plan. Ensure that the service plan exists, is available, and you have access to it.')
430436
end
431437

438+
def unavailable_service_plan!(service_plan)
439+
unprocessable!("Invalid service plan. The service plan #{service_plan} has been removed from the service broker's catalog. It is not possible to create new service instances using this plan.")
440+
end
441+
432442
def service_plan_not_visible_in_space!
433-
unprocessable!('Invalid service plan. Ensure that the service plan is visible in your current space and still available in the broker\'s catalog.')
443+
unprocessable!('Invalid service plan. Ensure that the service plan is visible in your current space.')
434444
end
435445

436446
def invalid_service_plan_relation!

spec/request/service_instances_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,7 @@ def check_filtered_instances(*instances)
12601260
expect(last_response).to have_status_code(422)
12611261
expect(parsed_response['errors']).to include(
12621262
include({
1263-
'detail' => 'Invalid service plan. Ensure that the service plan is visible in your current space and still available in the broker\'s catalog.',
1263+
'detail' => 'Invalid service plan. Ensure that the service plan is visible in your current space.',
12641264
'title' => 'CF-UnprocessableEntity',
12651265
'code' => 10_008
12661266
})
@@ -1276,7 +1276,7 @@ def check_filtered_instances(*instances)
12761276
expect(last_response).to have_status_code(422)
12771277
expect(parsed_response['errors']).to include(
12781278
include({
1279-
'detail' => 'Invalid service plan. Ensure that the service plan is visible in your current space and still available in the broker\'s catalog.',
1279+
'detail' => "Invalid service plan. The service plan #{service_plan.name} has been removed from the service broker\'s catalog. It is not possible to create new service instances using this plan.",
12801280
'title' => 'CF-UnprocessableEntity',
12811281
'code' => 10_008
12821282
})
@@ -2413,7 +2413,7 @@ def check_filtered_instances(*instances)
24132413
expect(last_response).to have_status_code(422)
24142414
expect(parsed_response['errors']).to include(
24152415
include({
2416-
'detail' => 'Invalid service plan. Ensure that the service plan is visible in your current space and still available in the broker\'s catalog.',
2416+
'detail' => "Invalid service plan. The service plan #{service_plan.name} has been removed from the service broker\'s catalog. It is not possible to create new service instances using this plan.",
24172417
'title' => 'CF-UnprocessableEntity',
24182418
'code' => 10_008
24192419
})

0 commit comments

Comments
 (0)