Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/active_admin_import/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def encode_file

def unzip_file
Zip::File.open(file_path) do |zip_file|
self.file = Tempfile.new(CONST::TMP_FILE)
self.file = Tempfile.new(CONST::TMP_FILE, binmode: true)
data = zip_file.entries.select(&:file?).first.get_input_stream.read
file << data
file.close
Expand Down
14 changes: 14 additions & 0 deletions spec/import_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,20 @@ def upload_file!(name, ext = 'csv')
end
end
end

context 'when zipped with Win1251 file' do
let(:options) do
attributes = { force_encoding: :auto }
{ template_object: ActiveAdminImport::Model.new(attributes) }
end
it 'should import file' do
with_zipped_csv(:authors_win1251_win_endline) do
upload_file!(:authors_win1251_win_endline, :zip)
expect(page).to have_content 'Successfully imported 2 authors'
expect(Author.count).to eq(2)
end
end
end
end

context 'with different header attribute names' do
Expand Down