diff --git a/app/controllers/admin/urn_lists_controller.rb b/app/controllers/admin/urn_lists_controller.rb index c67b456e6..064c03f0a 100644 --- a/app/controllers/admin/urn_lists_controller.rb +++ b/app/controllers/admin/urn_lists_controller.rb @@ -15,10 +15,10 @@ def create if @urn_list.save UrnListImporterJob.perform_later(@urn_list) - return redirect_to admin_urn_lists_path + redirect_to admin_urn_lists_path end - - render action: :new + rescue ActionController::ParameterMissing + redirect_to new_admin_urn_list_path, alert: 'Please choose a file to upload' end def download diff --git a/spec/features/admin_can_upload_urn_list_spec.rb b/spec/features/admin_can_upload_urn_list_spec.rb index 36afd6034..c620374fb 100644 --- a/spec/features/admin_can_upload_urn_list_spec.rb +++ b/spec/features/admin_can_upload_urn_list_spec.rb @@ -24,4 +24,14 @@ expect(UrnListImporterJob).to have_been_enqueued end + + context 'without attaching a file' do + scenario 'displays an error' do + visit new_admin_urn_list_path + + click_button 'Upload' + + expect(page).to have_text 'Please choose a file to upload' + end + end end