File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,8 @@ def file_path
103103
104104 def encode_file
105105 data = File . read ( file_path )
106+ return if data . empty?
107+
106108 File . open ( file_path , 'w' ) do |f |
107109 f . write ( encode ( data ) )
108110 end
Original file line number Diff line number Diff line change @@ -424,6 +424,22 @@ def upload_file!(name, ext = 'csv')
424424 expect ( Author . count ) . to eq ( 2 )
425425 end
426426 end
427+
428+ context 'with empty csv and auto detect encoding' do
429+ let ( :options ) do
430+ attributes = { force_encoding : :auto }
431+ { template_object : ActiveAdminImport ::Model . new ( attributes ) }
432+ end
433+
434+ before do
435+ upload_file! ( :empty )
436+ end
437+
438+ it 'should render warning' do
439+ expect ( page ) . to have_content I18n . t ( 'active_admin_import.file_empty_error' )
440+ expect ( Author . count ) . to eq ( 0 )
441+ end
442+ end
427443 end
428444
429445 context 'with callback procs options' do
You can’t perform that action at this time.
0 commit comments