aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/test/models/attachments_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activestorage/test/models/attachments_test.rb')
-rw-r--r--activestorage/test/models/attachments_test.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/activestorage/test/models/attachments_test.rb b/activestorage/test/models/attachments_test.rb
index 29b83eb841..ce83ec27d2 100644
--- a/activestorage/test/models/attachments_test.rb
+++ b/activestorage/test/models/attachments_test.rb
@@ -136,9 +136,7 @@ class ActiveStorage::AttachmentsTest < ActiveSupport::TestCase
end
test "identify newly-attached, directly-uploaded blob" do
- # Simulate a direct upload.
- blob = create_blob_before_direct_upload(filename: "racecar.jpg", content_type: "application/octet-stream", byte_size: 1124062, checksum: "7GjDDNEQb4mzMzsW+MS0JQ==")
- ActiveStorage::Blob.service.upload(blob.key, file_fixture("racecar.jpg").open)
+ blob = directly_upload_file_blob(content_type: "application/octet-stream")
@user.avatar.attach(blob)
@@ -146,6 +144,18 @@ class ActiveStorage::AttachmentsTest < ActiveSupport::TestCase
assert_predicate @user.avatar, :identified?
end
+ test "identify and analyze newly-attached, directly-uploaded blob" do
+ blob = directly_upload_file_blob(content_type: "application/octet-stream")
+
+ perform_enqueued_jobs do
+ @user.avatar.attach blob
+ end
+
+ assert_equal true, @user.avatar.reload.metadata[:identified]
+ assert_equal 4104, @user.avatar.metadata[:width]
+ assert_equal 2736, @user.avatar.metadata[:height]
+ end
+
test "identify newly-attached blob only once" do
blob = create_file_blob
assert_predicate blob, :identified?