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

Commit 5dc6e31

Browse files
Brian Butzblgm
andcommitted
v3(services): fix documentation_url field
Fix the service offering documentation_url field when included in a service instance request. [#173447953](https://www.pivotaltracker.com/story/show/173447953) Co-authored-by: George Blue <gblue@pivotal.io>
1 parent b5da1a2 commit 5dc6e31

3 files changed

Lines changed: 18 additions & 9 deletions

File tree

app/decorators/field_service_instance_offering_decorator.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def decorate(hash, service_instances)
2525
offering_view[:name] = offering.name if @fields.include?('name')
2626
offering_view[:guid] = offering.guid if @fields.include?('guid')
2727
offering_view[:description] = offering.description if @fields.include?('description')
28-
offering_view[:documentation_url] = offering.documentation_url if @fields.include?('documentation_url')
28+
offering_view[:documentation_url] = extract_documentation_url(offering.extra) if @fields.include?('documentation_url')
2929
if @fields.include?('relationships.service_broker')
3030
offering_view[:relationships] = {
3131
service_broker: {
@@ -41,5 +41,14 @@ def decorate(hash, service_instances)
4141

4242
hash
4343
end
44+
45+
private
46+
47+
def extract_documentation_url(extra)
48+
metadata = JSON.parse(extra)
49+
metadata['documentation_url']
50+
rescue JSON::ParserError
51+
nil
52+
end
4453
end
4554
end

spec/request/service_instances_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
name: instance.service_plan.service.name,
145145
guid: instance.service_plan.service.guid,
146146
description: instance.service_plan.service.description,
147-
documentation_url: instance.service_plan.service.documentation_url,
147+
documentation_url: 'https://some.url.for.docs/',
148148
}
149149
],
150150
service_brokers: [
@@ -407,7 +407,7 @@ def check_filtered_instances(*instances)
407407
name: msi_1.service_plan.service.name,
408408
guid: msi_1.service_plan.service.guid,
409409
description: msi_1.service_plan.service.description,
410-
documentation_url: msi_1.service_plan.service.documentation_url,
410+
documentation_url: 'https://some.url.for.docs/',
411411
relationships: {
412412
service_broker: {
413413
data: {
@@ -420,7 +420,7 @@ def check_filtered_instances(*instances)
420420
name: msi_2.service_plan.service.name,
421421
guid: msi_2.service_plan.service.guid,
422422
description: msi_2.service_plan.service.description,
423-
documentation_url: msi_2.service_plan.service.documentation_url,
423+
documentation_url: 'https://some.url.for.docs/',
424424
relationships: {
425425
service_broker: {
426426
data: {
@@ -433,7 +433,7 @@ def check_filtered_instances(*instances)
433433
name: ssi.service_plan.service.name,
434434
guid: ssi.service_plan.service.guid,
435435
description: ssi.service_plan.service.description,
436-
documentation_url: ssi.service_plan.service.documentation_url,
436+
documentation_url: 'https://some.url.for.docs/',
437437
relationships: {
438438
service_broker: {
439439
data: {

spec/unit/decorators/field_service_instance_offering_decorator_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
module VCAP::CloudController
55
RSpec.describe FieldServiceInstanceOfferingDecorator do
66
describe '.decorate' do
7-
let(:offering1) { Service.make }
8-
let(:offering2) { Service.make }
7+
let(:offering1) { Service.make(extra: '{"documentation_url": "https://offering1.com"}') }
8+
let(:offering2) { Service.make(extra: '{"documentation_url": "https://offering2.com"}') }
99

1010
let(:plan1) { ServicePlan.make(service: offering1) }
1111
let(:plan2) { ServicePlan.make(service: offering2) }
@@ -91,10 +91,10 @@ module VCAP::CloudController
9191
monkeys: %w(zach greg),
9292
service_offerings: [
9393
{
94-
documentation_url: offering1.documentation_url,
94+
documentation_url: 'https://offering1.com',
9595
},
9696
{
97-
documentation_url: offering2.documentation_url,
97+
documentation_url: 'https://offering2.com',
9898
}
9999
]
100100
}

0 commit comments

Comments
 (0)