diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2017-07-21 16:34:18 -0500 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2017-07-21 16:34:18 -0500 |
commit | 08d84e225cca6772aa54dfb7123120fe1070ea30 (patch) | |
tree | 6072999648420a121078ac0acdac92e39a257328 | |
parent | b6fd579a7e97f1a3aee27d22e12784f7a6155799 (diff) | |
download | rails-08d84e225cca6772aa54dfb7123120fe1070ea30.tar.gz rails-08d84e225cca6772aa54dfb7123120fe1070ea30.tar.bz2 rails-08d84e225cca6772aa54dfb7123120fe1070ea30.zip |
Extract test helper for image blob fixtures
-rw-r--r-- | test/controllers/variants_controller.rb | 6 | ||||
-rw-r--r-- | test/test_helper.rb | 6 | ||||
-rw-r--r-- | test/variant_test.rb | 4 |
3 files changed, 9 insertions, 7 deletions
diff --git a/test/controllers/variants_controller.rb b/test/controllers/variants_controller.rb index 132d93a3cf..22f5ec1454 100644 --- a/test/controllers/variants_controller.rb +++ b/test/controllers/variants_controller.rb @@ -6,12 +6,10 @@ require "active_storage/verified_key_with_expiration" 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 diff --git a/test/test_helper.rb b/test/test_helper.rb index 7aa7b50bf3..69ba76b9c4 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -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" diff --git a/test/variant_test.rb b/test/variant_test.rb index ee3bc5c0e5..0368960fbf 100644 --- a/test/variant_test.rb +++ b/test/variant_test.rb @@ -4,9 +4,7 @@ require "active_storage/variant" 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 |