From ba97d13f692462fb2551f34a93de745fe2452f78 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Tue, 29 Oct 2024 10:40:33 -0700 Subject: [PATCH] Update importers_controller_spec.rb --- .../bulkrax/importers_controller_spec.rb | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/spec/controllers/bulkrax/importers_controller_spec.rb b/spec/controllers/bulkrax/importers_controller_spec.rb index 569360c5..b6739ebd 100644 --- a/spec/controllers/bulkrax/importers_controller_spec.rb +++ b/spec/controllers/bulkrax/importers_controller_spec.rb @@ -131,6 +131,23 @@ def current_user post :create, params: { importer: valid_attributes, commit: 'Create and Validate' }, session: valid_session end end + + let(:file) { fixture_file_upload('./spec/fixtures/files/ok.csv') } + let(:uploaded_file) { Hyrax::UploadedFile.create(file: file) } + + context 'with file uploads' do + it 'assigns uploaded files correctly during creation' do + post :create, params: { importer: valid_attributes, uploaded_files: [uploaded_file.id] }, session: valid_session + expect(assigns(:importer).parser_fields['import_file_path']).to be_present + end + + it 'assigns uploaded files correctly during update' do + importer = Importer.create! valid_attributes + put :update, params: { id: importer.to_param, importer: valid_attributes, uploaded_files: [uploaded_file.id] }, session: valid_session + importer.reload + expect(importer.parser_fields['import_file_path']).to be_present + end + end end describe 'PUT #update' do @@ -165,6 +182,23 @@ def current_user expect(response).to be_successful end end + + let(:file) { fixture_file_upload('./spec/fixtures/files/ok.csv') } + let(:uploaded_file) { Hyrax::UploadedFile.create(file: file) } + + context 'with file uploads' do + it 'assigns uploaded files correctly during creation' do + post :create, params: { importer: valid_attributes, uploaded_files: [uploaded_file.id] }, session: valid_session + expect(assigns(:importer).parser_fields['import_file_path']).to be_present + end + + it 'assigns uploaded files correctly during update' do + importer = Importer.create! valid_attributes + put :update, params: { id: importer.to_param, importer: valid_attributes, uploaded_files: [uploaded_file.id] }, session: valid_session + importer.reload + expect(importer.parser_fields['import_file_path']).to be_present + end + end end describe 'PUT #continue' do