Skip to content

Commit

Permalink
Return publishing app for host Editions
Browse files Browse the repository at this point in the history
This returns the publishing app name for all host
editions (Editions with Embedded content in them)

In this previous Whitehal PR [1] we send publish
intents for host Documents of embedded content,
but we hardcoded the publishing app to Whitehall -
we need to see the correct publishing app for all
host editions in order to send these intents.

[1] alphagov/whitehall#9447
  • Loading branch information
Harriethw committed Sep 20, 2024
1 parent c7e4576 commit 12341f0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/presenters/queries/embedded_content_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def results
title: edition.title,
base_path: edition.base_path,
document_type: edition.document_type,
publishing_app: edition.publishing_app,
primary_publishing_organisation: {
content_id: edition.primary_publishing_organisation_content_id,
title: edition.primary_publishing_organisation_title,
Expand Down
3 changes: 2 additions & 1 deletion app/queries/get_embedded_content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def host_editions
.joins("LEFT JOIN editions AS org_editions ON org_editions.document_id = documents.id")
.where(links: { link_type: embedded_link_type, target_content_id: })
.select(
"editions.id, editions.title, editions.base_path, editions.document_type, primary_links.target_content_id AS primary_publishing_organisation_content_id",
"editions.id, editions.title, editions.base_path, editions.document_type, editions.publishing_app",
"primary_links.target_content_id AS primary_publishing_organisation_content_id",
"org_editions.title AS primary_publishing_organisation_title",
"org_editions.base_path AS primary_publishing_organisation_base_path",
)
Expand Down
2 changes: 2 additions & 0 deletions spec/integration/embedded_content_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
context "when an edition embeds a reference to the content block" do
it "returns details of the edition and its publishing organisation in the results" do
host_edition = create(:live_edition,
publishing_app: "whitehall",
details: {
"body" => "<p>{{embed:email_address:#{content_block.content_id}}}</p>\n",
},
Expand All @@ -64,6 +65,7 @@
"title" => host_edition.title,
"base_path" => host_edition.base_path,
"document_type" => host_edition.document_type,
"publishing_app" => host_edition.publishing_app,
"primary_publishing_organisation" => {
"content_id" => publishing_organisation.content_id,
"title" => publishing_organisation.title,
Expand Down
2 changes: 2 additions & 0 deletions spec/presenters/queries/embedded_content_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
title: "foo",
base_path: "/foo",
document_type: "publication",
publishing_app: "publisher",
primary_publishing_organisation_content_id: organisation_edition_id,
primary_publishing_organisation_title: "bar",
primary_publishing_organisation_base_path: "/bar")]
Expand All @@ -25,6 +26,7 @@
title: "foo",
base_path: "/foo",
document_type: "publication",
publishing_app: "publisher",
primary_publishing_organisation: {
content_id: organisation_edition_id,
title: "bar",
Expand Down
8 changes: 6 additions & 2 deletions spec/queries/get_embedded_content_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,17 @@
links_hash: {
primary_publishing_organisation: [organisation.content_id],
embed: [target_content_id],
})
},
publishing_app: "example-app")
draft_host_editions = create_list(:edition, 2,
details: {
body: "<p>{{embed:email_address:#{target_content_id}}}</p>\n",
},
links_hash: {
primary_publishing_organisation: [organisation.content_id],
embed: [target_content_id],
})
},
publishing_app: "another-app")

_unwanted_edition = create(:live_edition)

Expand All @@ -86,6 +88,7 @@
title: host_edition.title,
base_path: host_edition.base_path,
document_type: host_edition.document_type,
publishing_app: host_edition.publishing_app,
primary_publishing_organisation_content_id: organisation.content_id,
primary_publishing_organisation_title: organisation.title,
primary_publishing_organisation_base_path: organisation.base_path)
Expand All @@ -97,6 +100,7 @@
title: edition_double.title,
base_path: edition_double.base_path,
document_type: edition_double.document_type,
publishing_app: edition_double.publishing_app,
primary_publishing_organisation_content_id: edition_double.primary_publishing_organisation_content_id,
primary_publishing_organisation_title: edition_double.primary_publishing_organisation_title,
primary_publishing_organisation_base_path: edition_double.primary_publishing_organisation_base_path,
Expand Down

0 comments on commit 12341f0

Please sign in to comment.