From 972104e3f72be782ed51a221fc6406c86a4e43d1 Mon Sep 17 00:00:00 2001 From: tamsin johnson Date: Thu, 26 Oct 2023 08:07:29 -0700 Subject: [PATCH] rework `:with_files` factory to work with ActiveFedora/Wings Fedora builds FileMetadata nodes when files are uploaded, and creating them directly isn't allowed. `Hyrax::ValkyrieUpload` supports the specialized needs of the adapter, so use it to do this step for portability. --- spec/factories/hyrax_file_set.rb | 9 ++++++++- spec/presenters/hyrax/file_set_presenter_spec.rb | 1 - 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/spec/factories/hyrax_file_set.rb b/spec/factories/hyrax_file_set.rb index 74a17e55c3..f022c34eef 100644 --- a/spec/factories/hyrax_file_set.rb +++ b/spec/factories/hyrax_file_set.rb @@ -62,7 +62,14 @@ trait :with_files do transient do - files { [valkyrie_create(:hyrax_file_metadata), valkyrie_create(:hyrax_file_metadata)] } + ios { [File.open('spec/fixtures/image.png'), File.open('spec/fixtures/Example.ogg')] } + + after(:create) do |file_set, evaluator| + evaluator.ios.each do |file| + filename = File.basename(file.path).to_s + Hyrax::ValkyrieUpload.file(filename: filename, file_set: file_set, io: file) + end + end end end diff --git a/spec/presenters/hyrax/file_set_presenter_spec.rb b/spec/presenters/hyrax/file_set_presenter_spec.rb index 8a5c38f17f..f34619745c 100644 --- a/spec/presenters/hyrax/file_set_presenter_spec.rb +++ b/spec/presenters/hyrax/file_set_presenter_spec.rb @@ -324,7 +324,6 @@ def uri_segment_escape(uri) context 'with a file' do let(:file_set) do FactoryBot.valkyrie_create(:hyrax_file_set, - :with_files, files: [file_metadata], original_file: file_metadata) end