Skip to content

Commit

Permalink
Update importers_controller_spec.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
ShanaLMoore committed Oct 29, 2024
1 parent c714053 commit ba97d13
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions spec/controllers/bulkrax/importers_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ba97d13

Please sign in to comment.