From 531144e6ddd7c5829afcdda09a87b630fe723974 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Fri, 24 Dec 2021 05:30:56 +0000 Subject: [PATCH] Fixes for Style/FileWrite offense introduced in RuboCop 1.24.0 (#35136). git-svn-id: http://svn.redmine.org/redmine/trunk@21322 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- config/initializers/10-patches.rb | 2 +- test/test_helper.rb | 4 +--- test/unit/attachment_test.rb | 4 +--- 3 files changed, 3 insertions(+), 7 deletions(-) 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 -- 2.39.5