From 30900b5fa717f48688af29dd43580dae37325688 Mon Sep 17 00:00:00 2001 From: ChrisBAshton Date: Wed, 4 Dec 2024 14:12:29 +0000 Subject: [PATCH] Remove legacy test about asset variant URL including original ID There are now no attachment types (other than images and their variants) that result in anything other than the 'original' file being uploaded to Asset Manager. Whilst I could have changed this test to test a model that DOES have variants (i.e. ImageData), with code something like what I've put below, this behaviour is already covered by the "constructs the url of the file using the assets root, media, asset_manager_id and filename" test in this file, so I've deleted it instead. ``` asset_path = "path/to/asset.png" model = ImageData.new model.id = 1 model.assets << build(:asset, asset_manager_id: @asset_manager_id, variant: Asset.variants[:s216], filename: "asset_216.png") file = Whitehall::AssetManagerStorage::File.new(asset_path, model, "s216") assert_equal "http://assets-host/media/#{@asset_manager_id}/asset_216.png", file.url ``` --- test/unit/lib/whitehall/asset_manager_storage_test.rb | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/test/unit/lib/whitehall/asset_manager_storage_test.rb b/test/unit/lib/whitehall/asset_manager_storage_test.rb index 8d69d80b643..46708fa0dde 100644 --- a/test/unit/lib/whitehall/asset_manager_storage_test.rb +++ b/test/unit/lib/whitehall/asset_manager_storage_test.rb @@ -53,17 +53,6 @@ class Whitehall::AssetManagerStorage::FileTest < ActiveSupport::TestCase assert_equal "http://assets-host/media/asset_manager_id/sample.docx", model.file.url end - # TODO: commented out to get the tests passing. - # We should look at this again with fresh eyes - are we testing the right thing? - # - # test "returns file url using asset_manager_id when the model has an asset variant" do - # model = build(:attachment_data, attachable: build(:draft_edition, id: 1)) - # model.save! - # model.reload - - # assert_equal "http://assets-host/media/asset_manager_id_thumbnail/thumbnail_greenpaper.pdf.png", model.file.url(:thumbnail) - # end - # TODO: commented out to get the tests passing. # We should better understand how to rewrite this test and whether it is still valuable. #