Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content-modelling/550 Return publishing app for host Editions #2876

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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