dest_dir = File.join(Rails.root, 'tmp', 'emails')
Dir.mkdir(dest_dir) unless File.directory?(dest_dir)
filename = "#{Time.now.to_i}_#{mail.message_id.gsub(/[<>]/, '')}.eml"
- File.open(File.join(dest_dir, filename), 'wb') {|f| f.write(mail.encoded) }
+ File.binwrite(File.join(dest_dir, filename), mail.encoded)
end
end
end
def save_pdf
assert_equal 'application/pdf', response.media_type
filename = "#{self.class.name.underscore}__#{method_name}.pdf"
- File.open(File.join($redmine_tmp_pdf_directory, filename), "wb") do |f|
- f.write response.body
- end
+ File.binwrite(File.join($redmine_tmp_pdf_directory, filename), response.body)
end
end
a = Attachment.find(20)
assert a.disk_directory.blank?
# Create a real file for this fixture
- File.open(a.diskfile, "w") do |f|
- f.write "test file at the root of files directory"
- end
+ File.write(a.diskfile, 'test file at the root of files directory')
assert a.readable?
Attachment.move_from_root_to_target_directory