Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/models/services/service_binding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ def active_per_instance
order: [Sequel.desc(:created_at), Sequel.desc(:id)]
).as(:_rn)
end.
from_self.where(_rn: 1)
from_self.where(_rn: 1).
order_by(:id)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,24 @@ module VCAP::CloudController
end
end

context 'when there are multiple service bindings for the same service offering and plan' do
let!(:service_instance_2) { ManagedServiceInstance.make(space: space, service_plan: service_plan, name: 'instance-2') }
let!(:service_instance_3) { ManagedServiceInstance.make(space: space, service_plan: service_plan, name: 'instance-3') }
let!(:service_binding_2) { ServiceBinding.make(app: app, service_instance: service_instance_2) }
let!(:service_binding_3) { ServiceBinding.make(app: app, service_instance: service_instance_3) }

it 'returns bindings in natural order by id' do
bindings = system_env_presenter.system_env[:VCAP_SERVICES][service.label.to_sym]
expect(bindings).to have(3).items

actual_binding_order = bindings.map { |b| b.to_hash[:binding_guid] }

expected_binding_order = [service_binding, service_binding_2, service_binding_3].map(&:guid)

expect(actual_binding_order).to eq(expected_binding_order)
end
end

describe 'volume mounts' do
context 'when the service binding has volume mounts' do
let!(:service_binding) do
Expand Down