diff --git a/config/initializers/10-patches.rb b/config/initializers/10-patches.rb index 28f4f3670..0e01e28a5 100644 --- a/config/initializers/10-patches.rb +++ b/config/initializers/10-patches.rb @@ -114,7 +114,7 @@ module DeliveryMethods 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 diff --git a/test/test_helper.rb b/test/test_helper.rb index c0eb0ba90..54dfaba9c 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -375,9 +375,7 @@ module Redmine 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 diff --git a/test/unit/attachment_test.rb b/test/unit/attachment_test.rb index a870e3697..954c44269 100644 --- a/test/unit/attachment_test.rb +++ b/test/unit/attachment_test.rb @@ -362,9 +362,7 @@ class AttachmentTest < ActiveSupport::TestCase 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