Extract test helper for image blob fixtures

上级 b6fd579a
......@@ -6,12 +6,10 @@
class ActiveStorage::VariantsControllerTest < ActionController::TestCase
setup do
@blob = ActiveStorage::Blob.create_after_upload! \
filename: "racecar.jpg", content_type: "image/jpeg",
io: File.open(File.expand_path("../../fixtures/files/racecar.jpg", __FILE__))
@routes = Routes
@controller = ActiveStorage::VariantsController.new
@blob = create_image_blob filename: "racecar.jpg"
end
test "showing variant inline" do
......
......@@ -33,6 +33,12 @@ class ActiveSupport::TestCase
def create_blob(data: "Hello world!", filename: "hello.txt", content_type: "text/plain")
ActiveStorage::Blob.create_after_upload! io: StringIO.new(data), filename: filename, content_type: content_type
end
def create_image_blob(filename: "racecar.jpg", content_type: "image/jpeg")
ActiveStorage::Blob.create_after_upload! \
io: File.open(File.expand_path("../fixtures/files/#{filename}", __FILE__)),
filename: filename, content_type: content_type
end
end
require "action_controller"
......
......@@ -4,9 +4,7 @@
class ActiveStorage::VariantTest < ActiveSupport::TestCase
setup do
@blob = ActiveStorage::Blob.create_after_upload! \
filename: "racecar.jpg", content_type: "image/jpeg",
io: File.open(File.expand_path("../fixtures/files/racecar.jpg", __FILE__))
@blob = create_image_blob filename: "racecar.jpg"
end
test "resized variation" do
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册