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

Commit 8f44194

Browse files
v3(tests): add tests for service key last operation in response
[#174252663](https://www.pivotaltracker.com/story/show/174252663)
1 parent 073d19f commit 8f44194

2 files changed

Lines changed: 22 additions & 7 deletions

File tree

spec/request/service_credential_bindings_spec.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,11 @@ def check_filtered_bindings(*bindings)
434434
end
435435

436436
describe 'key credential binding' do
437-
let(:key) { VCAP::CloudController::ServiceKey.make(service_instance: instance) }
437+
let(:key) do
438+
VCAP::CloudController::ServiceKey.make(service_instance: instance) do |binding|
439+
operate_on(binding)
440+
end
441+
end
438442
let(:instance) { VCAP::CloudController::ManagedServiceInstance.make(space: space) }
439443
let(:api_call) { ->(user_headers) { get "/v3/service_credential_bindings/#{key.guid}", nil, user_headers } }
440444
let(:expected_object) { expected_json(key) }
@@ -782,7 +786,7 @@ def check_filtered_bindings(*bindings)
782786

783787
context 'when an operation is still on going for the binding' do
784788
before do
785-
binding.save_with_new_operation({ type: 'create', state: 'in progress' })
789+
binding.save_with_attributes_and_new_operation({}, { type: 'create', state: 'in progress' })
786790
end
787791

788792
it 'should fail as not allowed' do
@@ -1933,7 +1937,8 @@ def last_operation(binding)
19331937
end
19341938

19351939
def operate_on(binding)
1936-
binding.save_with_new_operation(
1940+
binding.save_with_attributes_and_new_operation(
1941+
{},
19371942
{
19381943
type: 'create',
19391944
state: 'succeeded',

spec/unit/presenters/v3/service_credential_binding_presenter_spec.rb

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ module CloudController
1010
describe 'app bindings' do
1111
let(:credential_binding) do
1212
ServiceBinding.make(name: 'some-name', guid: 'some-guid', app: app, service_instance: instance).tap do |binding|
13-
binding.save_with_new_operation(
13+
binding.save_with_attributes_and_new_operation(
14+
{},
1415
{
1516
type: 'create',
1617
state: 'succeeded',
@@ -101,12 +102,21 @@ module CloudController
101102

102103
describe 'key bindings' do
103104
let(:credential_binding) do
104-
ServiceKey.make(name: 'some-name', guid: 'some-guid', service_instance: instance)
105+
ServiceKey.make(name: 'some-name', guid: 'some-guid', service_instance: instance).tap do |binding|
106+
binding.save_with_attributes_and_new_operation(
107+
{},
108+
{
109+
type: 'create',
110+
state: 'succeeded',
111+
description: 'some description'
112+
}
113+
)
114+
end
105115
end
106116

107117
it 'should include the binding fields plus links and relationships' do
108118
presenter = described_class.new(credential_binding)
109-
expect(presenter.to_hash).to match(
119+
expect(presenter.to_hash.with_indifferent_access).to match(
110120
{
111121
guid: 'some-guid',
112122
type: 'key',
@@ -116,7 +126,7 @@ module CloudController
116126
last_operation: {
117127
type: 'create',
118128
state: 'succeeded',
119-
description: '',
129+
description: 'some description',
120130
updated_at: credential_binding.updated_at,
121131
created_at: credential_binding.created_at
122132
},

0 commit comments

Comments
 (0)