File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ def initialize(args = {})
4848 end
4949
5050 def assign_attributes ( args = { } , new_record = false )
51+ args [ :file ] = nil unless args . key? ( :file )
5152 @attributes . merge! ( args )
5253 @new_record = new_record
5354 args . keys . each do |key |
Original file line number Diff line number Diff line change @@ -588,4 +588,26 @@ def upload_file!(name, ext = 'csv')
588588 expect { add_author_resource ( options ) } . to raise_error ( ArgumentError )
589589 end
590590 end
591+
592+ context 'when submitting empty form after validation error' do
593+ let ( :options ) { { } }
594+
595+ before do
596+ add_author_resource ( options )
597+ visit '/admin/authors/import'
598+ end
599+
600+ it 'should NOT reuse cached file from previous submission' do
601+ expect do
602+ upload_file! ( :author_broken_header )
603+ expect ( page ) . to have_content ( "can't write unknown attribute" )
604+ end . not_to change { Author . count }
605+
606+ # Second submission without selecting a file
607+ expect do
608+ find_button ( 'Import' ) . click
609+ expect ( page ) . to have_content ( I18n . t ( 'active_admin_import.no_file_error' ) )
610+ end . not_to change { Author . count }
611+ end
612+ end
591613end
You can’t perform that action at this time.
0 commit comments