Use binread instead of setting file mode manually
Followup to b31022052a
.
This commit is contained in:
parent
f43e4a78bd
commit
96a1a2a37c
|
@ -4,7 +4,7 @@ require "abstract_unit"
|
|||
|
||||
module TestApiFileUtils
|
||||
def file_path() __FILE__ end
|
||||
def file_data() @data ||= File.open(file_path, "rb") { |f| f.read } end
|
||||
def file_data() @data ||= File.binread(file_path) end
|
||||
end
|
||||
|
||||
class DataStreamingApiController < ActionController::API
|
||||
|
|
|
@ -5,7 +5,7 @@ require "abstract_unit"
|
|||
module TestFileUtils
|
||||
def file_name() File.basename(__FILE__) end
|
||||
def file_path() __FILE__ end
|
||||
def file_data() @data ||= File.open(file_path, "rb") { |f| f.read } end
|
||||
def file_data() @data ||= File.binread(file_path) end
|
||||
end
|
||||
|
||||
class SendFileController < ActionController::Base
|
||||
|
|
|
@ -10,7 +10,7 @@ class ActiveRecord::FixtureSet::RenderContext # :nodoc:
|
|||
end
|
||||
|
||||
def binary(path)
|
||||
%(!!binary "#{Base64.strict_encode64(File.read(path, mode: 'rb'))}")
|
||||
%(!!binary "#{Base64.strict_encode64(File.binread(path))}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -529,7 +529,7 @@ class FixturesTest < ActiveRecord::TestCase
|
|||
end
|
||||
|
||||
def test_binary_in_fixtures
|
||||
data = File.open(ASSETS_ROOT + "/flowers.jpg", "rb") { |f| f.read }
|
||||
data = File.binread(ASSETS_ROOT + "/flowers.jpg")
|
||||
data.force_encoding("ASCII-8BIT")
|
||||
data.freeze
|
||||
assert_equal data, @flowers.data
|
||||
|
|
|
@ -611,7 +611,7 @@ module ApplicationTests
|
|||
default from: "from@example.com"
|
||||
|
||||
def foo
|
||||
attachments['pixel.png'] = File.read("#{app_path}/public/images/pixel.png", mode: 'rb')
|
||||
attachments['pixel.png'] = File.binread("#{app_path}/public/images/pixel.png")
|
||||
mail to: "to@example.org"
|
||||
end
|
||||
end
|
||||
|
@ -648,7 +648,7 @@ module ApplicationTests
|
|||
default from: "from@example.com"
|
||||
|
||||
def foo
|
||||
attachments['pixel.png'] = File.read("#{app_path}/public/images/pixel.png", mode: 'rb')
|
||||
attachments['pixel.png'] = File.binread("#{app_path}/public/images/pixel.png")
|
||||
mail to: "to@example.org"
|
||||
end
|
||||
end
|
||||
|
@ -693,7 +693,7 @@ module ApplicationTests
|
|||
default from: "from@example.com"
|
||||
|
||||
def foo
|
||||
attachments['pixel.png'] = File.read("#{app_path}/public/images/pixel.png", mode: 'rb')
|
||||
attachments['pixel.png'] = File.binread("#{app_path}/public/images/pixel.png")
|
||||
mail to: "to@example.org"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue