Skip to content

Commit 5a8cd96

Browse files
authored
Merge pull request #1264 from Crown-Commercial-Service/feature/nrmi-295-urn-upload-error-handling
Feature/nrmi 295 urn upload error handling
2 parents 0283e1a + 28b5fb3 commit 5a8cd96

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

app/controllers/admin/urn_lists_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ def create
1515
if @urn_list.save
1616
UrnListImporterJob.perform_later(@urn_list)
1717

18-
return redirect_to admin_urn_lists_path
18+
redirect_to admin_urn_lists_path
1919
end
20-
21-
render action: :new
20+
rescue ActionController::ParameterMissing
21+
redirect_to new_admin_urn_list_path, alert: 'Please choose a file to upload'
2222
end
2323

2424
def download

spec/features/admin_can_upload_urn_list_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,14 @@
2424

2525
expect(UrnListImporterJob).to have_been_enqueued
2626
end
27+
28+
context 'without attaching a file' do
29+
scenario 'displays an error' do
30+
visit new_admin_urn_list_path
31+
32+
click_button 'Upload'
33+
34+
expect(page).to have_text 'Please choose a file to upload'
35+
end
36+
end
2737
end

0 commit comments

Comments
 (0)