diff --git a/lib/engines/content_object_store/app/lib/content_object_store/publishable.rb b/lib/engines/content_object_store/app/lib/content_object_store/publishable.rb index 543e5a1be849..0149c07cb023 100644 --- a/lib/engines/content_object_store/app/lib/content_object_store/publishable.rb +++ b/lib/engines/content_object_store/app/lib/content_object_store/publishable.rb @@ -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 diff --git a/lib/engines/content_object_store/app/workers/content_object_store/publish_intent_worker.rb b/lib/engines/content_object_store/app/workers/content_object_store/publish_intent_worker.rb index a727fac801d6..840027d52575 100644 --- a/lib/engines/content_object_store/app/workers/content_object_store/publish_intent_worker.rb +++ b/lib/engines/content_object_store/app/workers/content_object_store/publish_intent_worker.rb @@ -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 diff --git a/lib/engines/content_object_store/test/integration/content_block/workflow_test.rb b/lib/engines/content_object_store/test/integration/content_block/workflow_test.rb index b8c68f2d31be..9e086de05a78 100644 --- a/lib/engines/content_object_store/test/integration/content_block/workflow_test.rb +++ b/lib/engines/content_object_store/test/integration/content_block/workflow_test.rb @@ -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", @@ -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" }], }] @@ -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", @@ -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" }], }] diff --git a/lib/engines/content_object_store/test/unit/app/services/publish_edition_service_test.rb b/lib/engines/content_object_store/test/unit/app/services/publish_edition_service_test.rb index d59262266d3d..fe5f28158cb8 100644 --- a/lib/engines/content_object_store/test/unit/app/services/publish_edition_service_test.rb +++ b/lib/engines/content_object_store/test/unit/app/services/publish_edition_service_test.rb @@ -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", @@ -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 diff --git a/lib/engines/content_object_store/test/unit/app/services/update_edition_service_test.rb b/lib/engines/content_object_store/test/unit/app/services/update_edition_service_test.rb index 81bb2b240230..b3071b7509b1 100644 --- a/lib/engines/content_object_store/test/unit/app/services/update_edition_service_test.rb +++ b/lib/engines/content_object_store/test/unit/app/services/update_edition_service_test.rb @@ -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", @@ -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) diff --git a/lib/engines/content_object_store/test/unit/app/workers/publish_intent_worker_test.rb b/lib/engines/content_object_store/test/unit/app/workers/publish_intent_worker_test.rb index d97abd3d2cc7..4e83af34e621 100644 --- a/lib/engines/content_object_store/test/unit/app/workers/publish_intent_worker_test.rb +++ b/lib/engines/content_object_store/test/unit/app/workers/publish_intent_worker_test.rb @@ -4,10 +4,11 @@ class ContentObjectStore::PublishIntentWorkerTest < ActiveSupport::TestCase test "#perform adds a publishing intent to the Publishing API" do base_path = "/base-path" timestamp = Time.zone.now.to_s + publishing_app = "publisher" publish_intent = { foo: "bar" } - PublishingApi::PublishIntentPresenter.expects(:new).with(base_path, timestamp).once.returns(publish_intent) + PublishingApi::PublishIntentPresenter.expects(:new).with(base_path, timestamp, publishing_app).once.returns(publish_intent) Services.publishing_api.expects(:put_intent).once.with(base_path, publish_intent.as_json) - ContentObjectStore::PublishIntentWorker.new.perform(base_path, timestamp) + ContentObjectStore::PublishIntentWorker.new.perform(base_path, publishing_app, timestamp) end end