-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add rake task to send content-item to publishing-api
This rake task will be run on every deploy (this is configured in the private alphagov-deployment repo). It will send the smart-answers to the content-store via the publishing-api.
- Loading branch information
Showing
4 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class ContentItemPublisher | ||
def publish(flow_presenters) | ||
flow_presenters.each do |smart_answer| | ||
content_item = FlowContentItem.new(smart_answer) | ||
Services.publishing_api.put_content_item(content_item.base_path, content_item.payload) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'gds_api/publishing_api' | ||
|
||
module Services | ||
def self.publishing_api | ||
@publishing_api ||= GdsApi::PublishingApi.new(Plek.new.find('publishing-api')) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace :publishing_api do | ||
desc "Publish smart answers to the content-store" | ||
task :publish => [:environment] do | ||
flow_presenters = RegisterableSmartAnswers.new.flow_presenters | ||
ContentItemPublisher.new.publish(flow_presenters) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require 'test_helper' | ||
|
||
class ContentItemPublisherTest < ActiveSupport::TestCase | ||
def test_sending_item_to_content_store | ||
request = stub_request(:put, "http://publishing-api.dev.gov.uk/content/a-flow-name") | ||
presenter = FlowRegistrationPresenter.new(stub('flow', name: 'a-flow-name', content_id: '3e6f33b8-0723-4dd5-94a2-cab06f23a685')) | ||
|
||
ContentItemPublisher.new.publish([presenter]) | ||
|
||
assert_requested request | ||
end | ||
end |