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

Commit 1fc22bf

Browse files
author
Derik Evangelista
committed
v3: Do not duplicate message errors for SI
[finishes #172332344](https://www.pivotaltracker.com/story/show/172332344)
1 parent 3224590 commit 1fc22bf

2 files changed

Lines changed: 30 additions & 6 deletions

File tree

app/messages/service_instance_create_managed_message.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ class ServiceInstanceCreateManagedMessage < ServiceInstanceCreateMessage
88
]
99

1010
validates_with NoAdditionalKeysValidator
11-
validates_with RelationshipValidator
1211

1312
validates :parameters, hash: true, allow_nil: true
1413
validates :type, allow_blank: false, inclusion: {

spec/unit/messages/service_instance_create_managed_message_spec.rb

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ module VCAP::CloudController
4343
expect(message.name).to eq('my-service-instance')
4444
expect(message.space_guid).to eq('space-guid')
4545
expect(message.service_plan_guid).to eq('service-plan-guid')
46-
expect(message.metadata[:labels]).to eq({ potato: 'mashed' })
47-
expect(message.metadata[:annotations]).to eq({ cheese: 'bono' })
46+
expect(message.metadata[:labels]).to eq(potato: 'mashed')
47+
expect(message.metadata[:annotations]).to eq(cheese: 'bono')
4848
expect(message.tags).to contain_exactly('foo', 'bar', 'baz')
49-
expect(message.parameters).to match({ foo: 'bar' })
49+
expect(message.parameters).to match(foo: 'bar')
5050
end
5151

5252
it 'accepts the minimal request' do
53-
message = described_class.new({
53+
message = described_class.new(
5454
type: 'managed',
5555
name: 'my-service-instance',
5656
relationships: {
@@ -61,7 +61,7 @@ module VCAP::CloudController
6161
data: { guid: 'service-plan-guid' }
6262
}
6363
}
64-
})
64+
)
6565
expect(message).to be_valid
6666
end
6767

@@ -87,6 +87,31 @@ module VCAP::CloudController
8787
expect(message.errors[:parameters]).to include('must be an object')
8888
end
8989
end
90+
91+
describe 'service plan relationship' do
92+
it 'fails when not present' do
93+
body[:relationships][:service_plan] = nil
94+
message.valid?
95+
expect(message).to_not be_valid
96+
expect(message.errors[:relationships]).to include(
97+
"Service plan can't be blank",
98+
/Service plan must be structured like this.*/
99+
)
100+
expect(message.errors[:relationships].count).to eq(2)
101+
end
102+
end
103+
104+
describe 'space relationship' do
105+
it 'fails when not present' do
106+
body[:relationships][:space] = nil
107+
expect(message).to_not be_valid
108+
expect(message.errors[:relationships]).to include(
109+
"Space can't be blank",
110+
/Space must be structured like this.*/,
111+
)
112+
expect(message.errors[:relationships].count).to eq(2)
113+
end
114+
end
90115
end
91116
end
92117
end

0 commit comments

Comments
 (0)