Skip to content

Commit

Permalink
HYC-1686 account for when no packages are selected
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharon Luong committed Jul 13, 2023
1 parent 3fce9c6 commit b9168d3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/controllers/ingest_from_ftp_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@ def view_status
end

def delete_packages
# need to instantiate source again for redirect
source
filenames_to_delete = params[:filenames_to_delete]
if filenames_to_delete.blank?
flash[:alert] = 'No packages were chosen'
redirect_to ingest_from_ftp_path(source: @source)
return
end
package_paths = list_package_files
package_paths.each do |package_path|
if filenames_to_delete.any? { |filename| package_path.include?(filename) }
Expand Down
7 changes: 7 additions & 0 deletions spec/controllers/ingest_from_ftp_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@
package_filepaths = Dir[File.join(proquest_dir.to_s, '*.zip')]
expect(package_filepaths.empty?).to eq true
end

it 'returns to same page with alert if no packages were chosen' do
post :delete_packages, params: { source: 'proquest', filenames_to_delete: []},
session: valid_session
expect(response).to redirect_to(ingest_from_ftp_path(source: 'proquest'))
expect(flash[:alert]).to be_present
end
end

context 'as a non-admin' do
Expand Down

0 comments on commit b9168d3

Please sign in to comment.