Skip to content

Commit b5b6664

Browse files
committed
fix test issues
1 parent ee0025f commit b5b6664

File tree

2 files changed

+16
-24
lines changed

2 files changed

+16
-24
lines changed

spec/request/service_credential_bindings_spec.rb

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,18 +1274,24 @@ def check_filtered_bindings(*bindings)
12741274
}))
12751275
end
12761276

1277-
it 'returns 422 when the binding already exists' do
1278-
api_call.call admin_headers
1279-
expect(last_response.status).to eq(201).or eq(202)
1277+
context 'when only one binding per app and service instance is allowed' do
1278+
before do
1279+
TestConfig.override(max_service_credential_bindings_per_app_service_instance: 1)
12801280

1281-
api_call.call admin_headers
1281+
it 'returns 422 when the binding already exists' do
1282+
api_call.call admin_headers
1283+
expect(last_response.status).to eq(201).or eq(202)
12821284

1283-
expect(last_response).to have_status_code(422)
1284-
expect(parsed_response['errors']).to include(include({
1285-
'detail' => include('The app is already bound to the service instance'),
1286-
'title' => 'CF-UnprocessableEntity',
1287-
'code' => 10_008
1288-
}))
1285+
api_call.call admin_headers
1286+
1287+
expect(last_response).to have_status_code(422)
1288+
expect(parsed_response['errors']).to include(include({
1289+
'detail' => include('The app is already bound to the service instance'),
1290+
'title' => 'CF-UnprocessableEntity',
1291+
'code' => 10_008
1292+
}))
1293+
end
1294+
end
12891295
end
12901296

12911297
context 'when the service instance does not exist' do

spec/unit/models/services/service_binding_spec.rb

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ module VCAP::CloudController
2525
it { is_expected.to validate_presence :app }
2626
it { is_expected.to validate_presence :service_instance }
2727
it { is_expected.to validate_db_presence :credentials }
28-
it { is_expected.to validate_uniqueness %i[app_guid service_instance_guid], message: 'The app is already bound to the service.' }
2928
it { is_expected.to validate_presence [:type] }
3029

3130
it 'validates max length of name' do
@@ -80,19 +79,6 @@ module VCAP::CloudController
8079
let(:app) { AppModel.make }
8180
let(:service_instance) { ServiceInstance.make(space: app.space) }
8281

83-
context 'and the name is not null' do
84-
let(:existing_binding) do
85-
ServiceBinding.make(app: app, name: 'some-name', service_instance: service_instance, type: 'app')
86-
end
87-
88-
it 'adds a uniqueness error' do
89-
other_service_instance = ServiceInstance.make(space: existing_binding.space)
90-
conflict = ServiceBinding.new(app: existing_binding.app, name: existing_binding.name, service_instance: other_service_instance, type: 'app')
91-
expect(conflict.valid?).to be(false)
92-
expect(conflict.errors.full_messages).to eq(['The binding name is invalid. App binding names must be unique. The app already has a binding with name \'some-name\'.'])
93-
end
94-
end
95-
9682
context 'and the name is null' do
9783
let(:existing_binding) do
9884
ServiceBinding.make(app: app, name: nil, service_instance: service_instance, type: 'app')

0 commit comments

Comments
 (0)