From 622987081769cd63a8fb0e67e9a98bbaa7aba9f4 Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Mon, 2 Mar 2020 10:20:00 +0000 Subject: [PATCH] Use a placeholder image from asset-manager In the past this linked to an image served by Whitehall, but because of the way Rails generates hashes for assets, we can't guarantee that this URL will always exist. This hasn't been a problem in the past because we've been able to put an unhashed version of the image on the Whitehall machines, but since moving to AWS the machines can be recreated at any moment and won't have the file. To solve this problem I've uploaded the file to Asset Manager and we can link to that instead. Ideally, we wouldn't depend on a file in a different application, but this solves the problem for now. --- app/presenters/content_item/news_image.rb | 3 ++- test/presenters/content_item/news_image_test.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/presenters/content_item/news_image.rb b/app/presenters/content_item/news_image.rb index 0a49663a5..595b7a5ce 100644 --- a/app/presenters/content_item/news_image.rb +++ b/app/presenters/content_item/news_image.rb @@ -12,7 +12,8 @@ def default_news_image end def placeholder_image - { "url" => "https://assets.publishing.service.gov.uk/government/assets/placeholder.jpg" } + # this image has been uploaded to asset-manager + { "url" => "https://assets.publishing.service.gov.uk/media/5e59279b86650c53b2cefbfe/placeholder.jpg" } end end end diff --git a/test/presenters/content_item/news_image_test.rb b/test/presenters/content_item/news_image_test.rb index a76f81b28..070dbd8d7 100644 --- a/test/presenters/content_item/news_image_test.rb +++ b/test/presenters/content_item/news_image_test.rb @@ -34,7 +34,7 @@ def initialize test "presents a placeholder image if document has no image or default news image" do item = DummyContentItem.new - placeholder_image = { "url" => "https://assets.publishing.service.gov.uk/government/assets/placeholder.jpg" } + placeholder_image = { "url" => "https://assets.publishing.service.gov.uk/media/5e59279b86650c53b2cefbfe/placeholder.jpg" } assert_equal placeholder_image, item.image end