Skip to content

Commit

Permalink
pass publishing app name to Publish Intents for Host Content
Browse files Browse the repository at this point in the history
We want to remove the cache Host Content that is not published by Whitehall,
as embedded content can be used across all Publishing apps.

[1] alphagov/publishing-api#2876
  • Loading branch information
Harriethw committed Sep 20, 2024
1 parent 1e5ff89 commit 44094d8
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ def remove_cache_for_host_content(content_block_edition:)
content_block_document: content_block_edition.document,
)
host_content_items.each do |host_content_item|
ContentObjectStore::PublishIntentWorker.perform_async(host_content_item.base_path, Time.zone.now.to_s)
ContentObjectStore::PublishIntentWorker.perform_async(
host_content_item.base_path,
host_content_item.publishing_app,
Time.zone.now.to_s,
)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ module ContentObjectStore
class PublishIntentWorker < WorkerBase
sidekiq_options queue: :content_block_publishing

def perform(base_path, publish_timestamp)
def perform(base_path, publishing_app, publish_timestamp)
publish_timestamp = Time.zone.parse(publish_timestamp)
publish_intent = PublishingApi::PublishIntentPresenter.new(base_path, publish_timestamp)
publish_intent = PublishingApi::PublishIntentPresenter.new(base_path, publish_timestamp, publishing_app)

Services.publishing_api.put_intent(base_path, publish_intent.as_json)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class ContentObjectStore::ContentBlock::WorkflowTest < ActionDispatch::Integrati
"document_type" => "document",
"base_path" => "/host-document",
"content_id" => "1234abc",
"publishing_app" => "host_publisher",
"primary_publishing_organisation" => {
"content_id" => "456abc",
"title" => "Organisation",
Expand All @@ -140,7 +141,7 @@ class ContentObjectStore::ContentBlock::WorkflowTest < ActionDispatch::Integrati
publishing_api_mock.expect :put_intent, {}, ["/host-document",
{
publish_time: Time.zone.now,
publishing_app: "whitehall",
publishing_app: "host_publisher",
rendering_app: "government-frontend",
routes: [{ path: "/host-document", type: "exact" }],
}]
Expand Down Expand Up @@ -280,6 +281,7 @@ class ContentObjectStore::ContentBlock::WorkflowTest < ActionDispatch::Integrati
"document_type" => "document",
"base_path" => "/host-document",
"content_id" => "1234abc",
"publishing_app" => "host_publisher",
"primary_publishing_organisation" => {
"content_id" => "456abc",
"title" => "Organisation",
Expand All @@ -299,7 +301,7 @@ class ContentObjectStore::ContentBlock::WorkflowTest < ActionDispatch::Integrati
publishing_api_mock.expect :put_intent, {}, ["/host-document",
{
publish_time: Time.zone.now,
publishing_app: "whitehall",
publishing_app: "host_publisher",
rendering_app: "government-frontend",
routes: [{ path: "/host-document", type: "exact" }],
}]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class ContentObjectStore::PublishEditionServiceTest < ActiveSupport::TestCase
"document_type" => "document",
"base_path" => "/host-document",
"content_id" => "1234abc",
"publishing_app" => "example-app",
"primary_publishing_organisation" => {
"content_id" => "456abc",
"title" => "Organisation",
Expand All @@ -93,7 +94,11 @@ class ContentObjectStore::PublishEditionServiceTest < ActiveSupport::TestCase

stub_publishing_api_has_embedded_content(content_id:, total: 0, results: host_content)

ContentObjectStore::PublishIntentWorker.expects(:perform_async).with("/host-document", Time.zone.now.to_s).once
ContentObjectStore::PublishIntentWorker.expects(:perform_async).with(
"/host-document",
"example-app",
Time.zone.now.to_s,
).once

ContentObjectStore::PublishEditionService.new(schema).call(edition)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ class ContentObjectStore::UpdateEditionServiceTest < ActiveSupport::TestCase
"document_type" => "document",
"base_path" => "/host-document",
"content_id" => "1234abc",
"publishing_app" => "example-app",
"primary_publishing_organisation" => {
"content_id" => "456abc",
"title" => "Organisation",
Expand All @@ -261,7 +262,11 @@ class ContentObjectStore::UpdateEditionServiceTest < ActiveSupport::TestCase

stub_publishing_api_has_embedded_content(content_id:, total: 0, results: dependent_content)

ContentObjectStore::PublishIntentWorker.expects(:perform_async).with("/host-document", Time.zone.now.to_s).once
ContentObjectStore::PublishIntentWorker.expects(:perform_async).with(
"/host-document",
"example-app",
Time.zone.now.to_s,
).once

ContentObjectStore::UpdateEditionService
.new(schema, @original_content_block_edition)
Expand Down

0 comments on commit 44094d8

Please sign in to comment.