]> source.dussan.org Git - redmine.git/commitdiff
Fixes for Style/FileWrite offense introduced in RuboCop 1.24.0 (#35136).
authorGo MAEDA <maeda@farend.jp>
Fri, 24 Dec 2021 05:30:56 +0000 (05:30 +0000)
committerGo MAEDA <maeda@farend.jp>
Fri, 24 Dec 2021 05:30:56 +0000 (05:30 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@21322 e93f8b46-1217-0410-a6f0-8f06a7374b81

config/initializers/10-patches.rb
test/test_helper.rb
test/unit/attachment_test.rb

index 28f4f367093ed430319db9355c1a1bd73f3b5e42..0e01e28a527bc1af79501f0dc018ab8e5a5e3f1c 100644 (file)
@@ -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
index c0eb0ba90188a803b31bc15ac200a316cf4dc170..54dfaba9cf008a240942d57aeb77ca40ec50c28f 100644 (file)
@@ -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
 
index a870e3697d2f00b2b4597e80782dadc5efbb6cf0..954c44269e0de68cb2bedc8799e78f1b7d7984ee 100644 (file)
@@ -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