From 447bb3d1ee1b6324aa440e746b556cded0548ca3 Mon Sep 17 00:00:00 2001 From: Ryan Brown Date: Fri, 28 Feb 2025 15:52:09 +0000 Subject: [PATCH] Add display type label to publication presenter The display type label is used to provide a human readable document type metadata value for search results on the official documents and research and statistics finders. --- app/presenters/publishing_api/publication_presenter.rb | 1 + .../admin/statistics_announcements_controller_test.rb | 5 ++++- .../presenters/publishing_api/publication_presenter_test.rb | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/presenters/publishing_api/publication_presenter.rb b/app/presenters/publishing_api/publication_presenter.rb index 52a16856ea9..7753f8d4029 100644 --- a/app/presenters/publishing_api/publication_presenter.rb +++ b/app/presenters/publishing_api/publication_presenter.rb @@ -70,6 +70,7 @@ def details details_hash = { body:, change_history: item.change_history.as_json, + document_type_label: item.display_type, documents:, featured_attachments:, emphasised_organisations: item.lead_organisations.map(&:content_id), diff --git a/test/functional/admin/statistics_announcements_controller_test.rb b/test/functional/admin/statistics_announcements_controller_test.rb index b911fef7724..c5b8e1a613d 100644 --- a/test/functional/admin/statistics_announcements_controller_test.rb +++ b/test/functional/admin/statistics_announcements_controller_test.rb @@ -236,8 +236,11 @@ class Admin::StatisticsAnnouncementsControllerTest < ActionController::TestCase ) publication_presenter = PublishingApiPresenters.presenter_for(national_statistics) - publication_content = publication_presenter.content.merge( + publication_content = publication_presenter.content.deep_merge( document_type: "official_statistics", + details: { + document_type_label: "Official Statistics", + }, ) html_attachment_presenter = PublishingApiPresenters.presenter_for(national_statistics.attachments.first) diff --git a/test/unit/app/presenters/publishing_api/publication_presenter_test.rb b/test/unit/app/presenters/publishing_api/publication_presenter_test.rb index 99a5aa2c3db..fc86536713f 100644 --- a/test/unit/app/presenters/publishing_api/publication_presenter_test.rb +++ b/test/unit/app/presenters/publishing_api/publication_presenter_test.rb @@ -40,6 +40,7 @@ def present(edition) tags: { browse_pages: [], }, + document_type_label: "Policy paper", documents: Whitehall::GovspeakRenderer.new.block_attachments(publication.attachments), first_public_at: publication.first_public_at, change_history: [