From 8e8f09fa187ad8b4567b68361e644a334741a7a0 Mon Sep 17 00:00:00 2001 From: Dwight Watson Date: Thu, 22 Mar 2018 14:16:36 +1100 Subject: 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 --- activestorage/test/test_helper.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'activestorage/test/test_helper.rb') 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 -- cgit v1.2.3