File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ def encode_file
110110
111111 def unzip_file
112112 Zip ::File . open ( file_path ) do |zip_file |
113- self . file = Tempfile . new ( CONST ::TMP_FILE )
113+ self . file = Tempfile . new ( CONST ::TMP_FILE , binmode : true )
114114 data = zip_file . entries . select ( &:file? ) . first . get_input_stream . read
115115 file << data
116116 file . close
Original file line number Diff line number Diff line change @@ -371,6 +371,20 @@ def upload_file!(name, ext = 'csv')
371371 end
372372 end
373373 end
374+
375+ context 'when zipped with Win1251 file' do
376+ let ( :options ) do
377+ attributes = { force_encoding : :auto }
378+ { template_object : ActiveAdminImport ::Model . new ( attributes ) }
379+ end
380+ it 'should import file' do
381+ with_zipped_csv ( :authors_win1251_win_endline ) do
382+ upload_file! ( :authors_win1251_win_endline , :zip )
383+ expect ( page ) . to have_content 'Successfully imported 2 authors'
384+ expect ( Author . count ) . to eq ( 2 )
385+ end
386+ end
387+ end
374388 end
375389
376390 context 'with different header attribute names' do
You can’t perform that action at this time.
0 commit comments