diff --git a/app/presenters/content_item/attachments.rb b/app/presenters/content_item/attachments.rb index 5842ce6da..ca26c41cc 100644 --- a/app/presenters/content_item/attachments.rb +++ b/app/presenters/content_item/attachments.rb @@ -1,15 +1,9 @@ module ContentItem module Attachments def attachment_details(attachment_id) - found_attachment = content_item.dig("details", "attachments")&.find do |attachment| + content_item.dig("details", "attachments")&.find do |attachment| attachment["id"] == attachment_id end - - return unless found_attachment - - found_attachment["attachment_id"] = found_attachment.delete("id") - found_attachment["owning_document_content_id"] = content_item["content_id"] - found_attachment end end end diff --git a/test/presenters/content_item/attachments_test.rb b/test/presenters/content_item/attachments_test.rb deleted file mode 100644 index 68bd5596f..000000000 --- a/test/presenters/content_item/attachments_test.rb +++ /dev/null @@ -1,49 +0,0 @@ -require "test_helper" - -class ContentItemAttachmentsTest < ActiveSupport::TestCase - class DummyContentItem - include ContentItem::Attachments - attr_reader :content_item, :attachment_id, :content_id - - def initialize - @attachment_id = 1234 - @content_id = SecureRandom.uuid - @content_item = { - "content_id" => content_id, - "details" => { - "attachments" => [ - { - "id" => attachment_id, - "title" => "Some title", - "url" => "some/url", - "alternative_format_contact_email" => "alternative.formats@education.gov.uk", - }, - ], - }, - } - end - end - - test "returns attachment details for found attachment" do - dummy = DummyContentItem.new - - details = dummy.attachment_details(dummy.attachment_id) - - assert_equal details, { - "title" => "Some title", - "url" => "some/url", - "alternative_format_contact_email" => "alternative.formats@education.gov.uk", - "attachment_id" => dummy.attachment_id, - "owning_document_content_id" => dummy.content_id, - } - end - - test "returns nil if no attachment found" do - attachment_id = 4321 - dummy = DummyContentItem.new - - details = dummy.attachment_details(attachment_id) - - assert_equal details, nil - end -end diff --git a/test/views/content_items/attachments.html.erb_test.rb b/test/views/content_items/attachments.html.erb_test.rb index 37f37d55d..913d549ba 100644 --- a/test/views/content_items/attachments.html.erb_test.rb +++ b/test/views/content_items/attachments.html.erb_test.rb @@ -14,17 +14,9 @@ class ContentItemsAttachmentsTest < ActionView::TestCase test "can render attachments using their metadata" do @content_item = PublicationPresenter.new( - { - "content_id" => "doc_content_id", - "details" => { - "attachments" => [ - { "id" => "attachment_id", - "title" => "Some title", - "url" => "some/url", - "alternative_format_contact_email" => "govuk_publishing_components@example.com" }, - ], - }, - }, + { "details" => { "attachments" => [{ "id" => "attachment_id", + "title" => "Some title", + "url" => "some/url" }] } }, "/publication", ApplicationController.new.view_context, ) @@ -38,7 +30,6 @@ class ContentItemsAttachmentsTest < ActionView::TestCase assert_includes rendered, "gem-c-attachment" assert_includes rendered, "Some title" - assert_includes rendered, "href=\"/contact/govuk/request-accessible-format?content_id=doc_content_id&attachment_id=attachment_id" end test "it prioritises pre-rendered attachments" do