Skip to content

Commit 2fdc366

Browse files
committed
Publish the content_item after putting
> v2 put_content sends the item as draft only. You need to also call `publish(content_id, update_type)` to actually mark the content as live and sent it to the live content-store.
1 parent 922ec30 commit 2fdc366

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

app/presenters/flow_content_item.rb

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ def payload
1313
format: 'placeholder_smart_answer',
1414
publishing_app: 'smartanswers',
1515
rendering_app: 'smartanswers',
16-
update_type: 'minor',
1716
locale: 'en',
1817
public_updated_at: Time.now.iso8601,
1918
routes: [

app/services/content_item_publisher.rb

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ def publish(flow_presenters)
33
flow_presenters.each do |smart_answer|
44
content_item = FlowContentItem.new(smart_answer)
55
Services.publishing_api.put_content(content_item.content_id, content_item.payload)
6+
Services.publishing_api.publish(content_item.content_id, 'minor')
67
end
78
end
89
end

test/unit/services/content_item_publisher_test.rb

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ class ContentItemPublisherTest < ActiveSupport::TestCase
77
end
88

99
test 'sending item to content store' do
10-
request = stub_request(:put, "http://publishing-api.dev.gov.uk/v2/content/3e6f33b8-0723-4dd5-94a2-cab06f23a685")
10+
draft_request = stub_request(:put, "http://publishing-api.dev.gov.uk/v2/content/3e6f33b8-0723-4dd5-94a2-cab06f23a685")
11+
publishing_request = stub_request(:post, "http://publishing-api.dev.gov.uk/v2/content/3e6f33b8-0723-4dd5-94a2-cab06f23a685/publish")
12+
1113
presenter = FlowRegistrationPresenter.new(stub('flow', name: 'bridge-of-death', content_id: '3e6f33b8-0723-4dd5-94a2-cab06f23a685'))
1214

1315
ContentItemPublisher.new.publish([presenter])
1416

15-
assert_requested request
17+
assert_requested draft_request
18+
assert_requested publishing_request
1619
end
1720
end

0 commit comments

Comments
 (0)