diff --git a/test/factories/attachment_data.rb b/test/factories/attachment_data.rb index 7526e34250b..231c358af79 100644 --- a/test/factories/attachment_data.rb +++ b/test/factories/attachment_data.rb @@ -6,7 +6,7 @@ content_type { AttachmentUploader::PDF_CONTENT_TYPE } after(:build) do |attachment_data| - attachment_data.assets << build(:asset, asset_manager_id: "asset_manager_id_original", variant: Asset.variants[:original], filename: attachment_data.filename) + attachment_data.assets << build(:asset, asset_manager_id: "asset_manager_id", variant: Asset.variants[:original], filename: attachment_data.filename) end end diff --git a/test/integration/asset_access_options_integration_test.rb b/test/integration/asset_access_options_integration_test.rb index 0a94a28842f..6ecb027fa4b 100644 --- a/test/integration/asset_access_options_integration_test.rb +++ b/test/integration/asset_access_options_integration_test.rb @@ -256,7 +256,7 @@ def setup_publishing_api_for(edition) def add_file_attachment_with_asset(filename, to:) to.attachments << FactoryBot.build( - :csv_attachment, + :file_attachment, title: filename, attachable: to, ) diff --git a/test/integration/attachment_deletion_integration_test.rb b/test/integration/attachment_deletion_integration_test.rb index b673eee3a1f..29cd80e07c5 100644 --- a/test/integration/attachment_deletion_integration_test.rb +++ b/test/integration/attachment_deletion_integration_test.rb @@ -11,9 +11,9 @@ class AttachmentDeletionIntegrationTest < ActionDispatch::IntegrationTest context "given a draft document with multiple file attachments" do let(:managing_editor) { create(:managing_editor) } let(:first_attachment) { build(:csv_attachment, attachable: edition, title: "first attachment") } - let(:first_asset_id) { "asset_manager_id" } + let(:first_asset_id) { first_attachment.attachment_data.assets.first.asset_manager_id } let(:second_attachment) { build(:file_attachment, attachable: edition) } - let(:second_asset_id_original) { "asset_manager_id_original" } + let(:second_asset_id) { second_attachment.attachment_data.assets.first.asset_manager_id } let(:edition) { create(:news_article) } before do @@ -24,7 +24,7 @@ class AttachmentDeletionIntegrationTest < ActionDispatch::IntegrationTest stub_publishing_api_expanded_links_with_taxons(edition.content_id, []) stub_asset(first_asset_id) - stub_asset(second_asset_id_original) + stub_asset(second_asset_id) edition.attachments << [first_attachment, second_attachment] edition.save! @@ -64,7 +64,7 @@ class AttachmentDeletionIntegrationTest < ActionDispatch::IntegrationTest it "deletes all corresponding assets in Asset Manager" do Services.asset_manager.expects(:delete_asset).once.with(first_asset_id) - Services.asset_manager.expects(:delete_asset).once.with(second_asset_id_original) + Services.asset_manager.expects(:delete_asset).once.with(second_asset_id) assert_equal AssetManagerAttachmentMetadataWorker.jobs.count, 2 AssetManagerAttachmentMetadataWorker.drain diff --git a/test/integration/attachment_draft_status_integration_test.rb b/test/integration/attachment_draft_status_integration_test.rb index 80c51a627fb..0887a510760 100644 --- a/test/integration/attachment_draft_status_integration_test.rb +++ b/test/integration/attachment_draft_status_integration_test.rb @@ -23,7 +23,7 @@ class AttachmentDraftStatusIntegrationTest < ActionDispatch::IntegrationTest before do setup_publishing_api_for(edition) - attachable.attachments << build(:csv_attachment, attachable:) + attachable.attachments << build(:file_attachment, attachable:) attachable.save! end diff --git a/test/integration/attachment_link_header_test.rb b/test/integration/attachment_link_header_test.rb index 20657cec282..322ba1ceca8 100644 --- a/test/integration/attachment_link_header_test.rb +++ b/test/integration/attachment_link_header_test.rb @@ -22,7 +22,7 @@ class AttachmentLinkHeaderIntegrationTest < ActionDispatch::IntegrationTest let(:topic_taxon) { build(:taxon_hash) } before do - attachable.attachments << build(:csv_attachment, attachable:) + attachable.attachments << build(:file_attachment, attachable:) attachable.save! end diff --git a/test/integration/attachment_redirect_due_to_unpublishing_integration_test.rb b/test/integration/attachment_redirect_due_to_unpublishing_integration_test.rb index 66792bbc35f..63279971758 100644 --- a/test/integration/attachment_redirect_due_to_unpublishing_integration_test.rb +++ b/test/integration/attachment_redirect_due_to_unpublishing_integration_test.rb @@ -21,7 +21,7 @@ class AttachmentRedirectDueToUnpublishingIntegrationTest < ActionDispatch::Integ stub_publishing_api_expanded_links_with_taxons(edition.content_id, []) stub_asset(asset_manager_id) - attachable.attachments << build(:csv_attachment, attachable:) + attachable.attachments << build(:file_attachment, attachable:) attachable.save! end diff --git a/test/unit/app/models/attachment_data_visibility_test.rb b/test/unit/app/models/attachment_data_visibility_test.rb index 0e734d6a0f6..82766a650b0 100644 --- a/test/unit/app/models/attachment_data_visibility_test.rb +++ b/test/unit/app/models/attachment_data_visibility_test.rb @@ -116,7 +116,7 @@ class AttachmentDataVisibilityTest < ActiveSupport::TestCase context "when attachment is replaced" do before do - replacement_attachment_data = build(:attachment_data_for_csv, to_replace_id: attachment_data.id, attachable:) + replacement_attachment_data = build(:attachment_data, to_replace_id: attachment_data.id, attachable:) attachment.update!(attachment_data: replacement_attachment_data) end diff --git a/test/unit/app/sidekiq/asset_manager_update_asset_worker_test.rb b/test/unit/app/sidekiq/asset_manager_update_asset_worker_test.rb index cda986dd4b7..139f45024df 100644 --- a/test/unit/app/sidekiq/asset_manager_update_asset_worker_test.rb +++ b/test/unit/app/sidekiq/asset_manager_update_asset_worker_test.rb @@ -8,8 +8,8 @@ class AssetManagerUpdateAssetWorkerTest < ActiveSupport::TestCase end let(:attachment_data) { FactoryBot.create(:attachment_data, attachable: create(:draft_publication)) } - test "updates an attachment and its variant" do - AssetManager::AssetUpdater.expects(:call).with("asset_manager_id_original", auth_bypass_id_attributes) + test "updates a file attachment's original asset" do + AssetManager::AssetUpdater.expects(:call).with("asset_manager_id", auth_bypass_id_attributes) AssetManagerUpdateAssetWorker.perform_async_in_queue("asset_manager_updater", "AttachmentData", attachment_data.id, auth_bypass_id_attributes) AssetManagerUpdateAssetWorker.drain diff --git a/test/unit/lib/tasks/asset_manager_test.rb b/test/unit/lib/tasks/asset_manager_test.rb index b213ef7fb76..682afada00e 100644 --- a/test/unit/lib/tasks/asset_manager_test.rb +++ b/test/unit/lib/tasks/asset_manager_test.rb @@ -15,7 +15,7 @@ class AssetManagerTest < ActiveSupport::TestCase %w[unpublished superseded].each do |state| context "for an asset attached only to a #{state} edition" do let(:edition) { create(:"#{state}_publication") } - let(:attachment) { create(:csv_attachment, attachable: edition) } + let(:attachment) { create(:file_attachment, attachable: edition) } context "when asset is not deleted from asset manager" do before do @@ -57,7 +57,7 @@ class AssetManagerTest < ActiveSupport::TestCase context "for an asset attached only to a draft edition" do let(:edition) { create(:draft_publication) } - let(:attachment) { create(:csv_attachment, attachable: edition) } + let(:attachment) { create(:file_attachment, attachable: edition) } context "when asset is not deleted from asset manager" do before do @@ -114,7 +114,7 @@ class AssetManagerTest < ActiveSupport::TestCase end context "for an asset attached to both published and superseded editions" do - let(:attachment) { create(:csv_attachment) } + let(:attachment) { create(:file_attachment) } let(:edition_1) { create(:superseded_publication, :with_alternative_format_provider, attachments: [attachment]) } let(:edition_2) { create(:published_publication, :with_alternative_format_provider, attachments: [attachment]) } @@ -144,7 +144,7 @@ class AssetManagerTest < ActiveSupport::TestCase end context "for an asset attached only to something that is not an edition" do - let(:attachment) { create(:csv_attachment, attachable: create(:double)) } + let(:attachment) { create(:file_attachment, attachable: create(:double)) } test "it should include no output in the report" do assert_output("") { task.invoke } diff --git a/test/unit/lib/whitehall/asset_manager_storage_test.rb b/test/unit/lib/whitehall/asset_manager_storage_test.rb index ea89ba003a6..d0a429e4e1b 100644 --- a/test/unit/lib/whitehall/asset_manager_storage_test.rb +++ b/test/unit/lib/whitehall/asset_manager_storage_test.rb @@ -46,11 +46,11 @@ class Whitehall::AssetManagerStorage::FileTest < ActiveSupport::TestCase end test "returns file url using asset_manager_id when the model has the original asset" do - model = build(:attachment_data_for_csv, attachable: build(:draft_edition, id: 1)) + model = build(:attachment_data, attachable: build(:draft_edition, id: 1)) model.save! model.reload - assert_equal "http://assets-host/media/asset_manager_id/sample.csv", model.file.url + assert_equal "http://assets-host/media/asset_manager_id/greenpaper.pdf", model.file.url end test "returns file url using asset_manager_id when the model has an asset variant" do