Skip to content

Commit

Permalink
Merge pull request #8908 from alphagov/use-ww-office-edition-links
Browse files Browse the repository at this point in the history
Use edition links for Worldwide Offices
  • Loading branch information
brucebolt authored Mar 20, 2024
2 parents 75f31c0 + 20dbf02 commit 4756da8
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 4756da8

Please sign in to comment.