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

Commit 5c72549

Browse files
author
Derik Evangelista
committed
v3(services): use SIs name when binding name is not set
[#173129426](https://www.pivotaltracker.com/story/show/173129426)
1 parent 0c01b0a commit 5c72549

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

app/presenters/v3/service_credential_binding_presenter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class ServiceCredentialBindingPresenter < BasePresenter
88
def to_hash
99
{
1010
guid: @resource.guid,
11-
name: @resource.name,
11+
name: @resource.name || @resource.service_instance.name,
1212
created_at: @resource.created_at,
1313
updated_at: @resource.updated_at,
1414
type: type

spec/unit/presenters/v3/service_credential_binding_presenter_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ module CloudController
6262
}
6363
)
6464
end
65+
66+
context 'when name is not set' do
67+
let(:instance) { ServiceInstance.make(name: 'smashed-avocado') }
68+
let(:credential_binding) { ServiceBinding.make(service_instance: instance) }
69+
70+
it 'should return the service instance name as the binding name' do
71+
presenter = described_class.new(credential_binding)
72+
expect(presenter.to_hash[:name]).to eq('smashed-avocado')
73+
end
74+
end
6575
end
6676

6777
describe 'key bindings' do

0 commit comments

Comments
 (0)