Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Commit 6458015

Browse files
Service broker considered available if state is empty
for compatibility with v2 [#172976573](https://www.pivotaltracker.com/story/show/172976573)
1 parent ba57325 commit 6458015

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

app/models/services/service_broker.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def in_transitional_state?
3939
end
4040

4141
def available?
42-
self.state == ServiceBrokerStateEnum::AVAILABLE
42+
self.state.blank? || self.state == ServiceBrokerStateEnum::AVAILABLE
4343
end
4444

4545
def space_scoped?

spec/request/service_instances_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,16 @@ def check_filtered_instances(*instances)
931931
end
932932
end
933933

934+
context 'when the service broker does not have state (v2 brokers)' do
935+
let(:service_broker) { service_plan.service_broker }
936+
937+
it 'creates a service instance' do
938+
service_broker.update(state: '')
939+
api_call.call(space_dev_headers)
940+
expect(last_response).to have_status_code(202)
941+
end
942+
end
943+
934944
context 'when there is an operation in progress for the service broker' do
935945
let(:service_broker) { service_plan.service_broker }
936946

spec/unit/models/services/service_broker_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ module VCAP::CloudController
108108
broker.state = ServiceBrokerStateEnum::AVAILABLE
109109
expect(broker.available?).to eq true
110110
end
111+
it 'returns true when state is empty to support old brokers' do
112+
broker.state = ''
113+
expect(broker.available?).to eq true
114+
end
111115
it 'returns false when state is DELETE_IN_PROGRESS' do
112116
broker.state = ServiceBrokerStateEnum::DELETE_IN_PROGRESS
113117
expect(broker.available?).to eq false

0 commit comments

Comments
 (0)