Skip to content

Commit

Permalink
Use edition links for Worldwide Offices
Browse files Browse the repository at this point in the history
We are working to make Worldwide Organisations and their offices
editionable.

Therefore we need to be able to link the links to editions, rather than
documents, to prevent draft updates becoming live before publication.
  • Loading branch information
brucebolt committed Mar 19, 2024
1 parent d4a3f6c commit 20dbf02
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
11 changes: 10 additions & 1 deletion app/presenters/publishing_api/worldwide_office_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def content
type: item.worldwide_office_type.name,
},
document_type: item.class.name.underscore,
links: edition_links,
public_updated_at: item.updated_at,
rendering_app: Whitehall::RenderingApp::GOVERNMENT_FRONTEND,
schema_name: "worldwide_office",
Expand All @@ -31,14 +32,22 @@ def content
content.merge!(PayloadBuilder::PolymorphicPath.for(item))
end

def links
def edition_links
{
contact:,
parent: [item.worldwide_organisation.content_id],
worldwide_organisation: [item.worldwide_organisation.content_id],
}
end

def links
{
contact: [],
parent: [],
worldwide_organisation: [],
}
end

private

def contact
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,23 @@ def present(...)
type: worldwide_office.worldwide_office_type.name,
},
update_type: "major",
links: {
contact: [
worldwide_office.contact.content_id,
],
parent: [
worldwide_office.worldwide_organisation.content_id,
],
worldwide_organisation: [
worldwide_office.worldwide_organisation.content_id,
],
},
}

expected_links = {
contact: [
worldwide_office.contact.content_id,
],
parent: [
worldwide_office.worldwide_organisation.content_id,
],
worldwide_organisation: [
worldwide_office.worldwide_organisation.content_id,
],
contact: [],
parent: [],
worldwide_organisation: [],
}

presented_item = present(worldwide_office)
Expand Down

0 comments on commit 20dbf02

Please sign in to comment.