aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/test/test_helper.rb
diff options
context:
space:
mode:
authorDwight Watson <dwightwatson@me.com>2018-03-22 14:16:36 +1100
committerDwight Watson <dwightwatson@me.com>2018-03-27 12:58:19 +1100
commit8e8f09fa187ad8b4567b68361e644a334741a7a0 (patch)
tree3dca02ef7a693d5d030dc013f1dbb377b5f4579f /activestorage/test/test_helper.rb
parent4c9c3ffc2e80155f31dbcf80591618ed1c858685 (diff)
downloadrails-8e8f09fa187ad8b4567b68361e644a334741a7a0.tar.gz
rails-8e8f09fa187ad8b4567b68361e644a334741a7a0.tar.bz2
rails-8e8f09fa187ad8b4567b68361e644a334741a7a0.zip
Flip the order of the after_create callbacks
Addresses rails/rails#32247 Add test that checks identify and analyze work in correct order Break out direct upload test helper Review changes for direct-upload test helper
Diffstat (limited to 'activestorage/test/test_helper.rb')
-rw-r--r--activestorage/test/test_helper.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activestorage/test/test_helper.rb b/activestorage/test/test_helper.rb
index 2a8e153303..043890832d 100644
--- a/activestorage/test/test_helper.rb
+++ b/activestorage/test/test_helper.rb
@@ -54,6 +54,16 @@ class ActiveSupport::TestCase
ActiveStorage::Blob.create_before_direct_upload! filename: filename, byte_size: byte_size, checksum: checksum, content_type: content_type
end
+ def directly_upload_file_blob(filename: "racecar.jpg", content_type: "image/jpeg")
+ file = file_fixture(filename)
+ byte_size = file.size
+ checksum = Digest::MD5.file(file).base64digest
+
+ create_blob_before_direct_upload(filename: filename, byte_size: byte_size, checksum: checksum, content_type: content_type).tap do |blob|
+ ActiveStorage::Blob.service.upload(blob.key, file.open)
+ end
+ end
+
def read_image(blob_or_variant)
MiniMagick::Image.open blob_or_variant.service.send(:path_for, blob_or_variant.key)
end