diff options
author | Dwight Watson <dwightwatson@me.com> | 2018-03-22 14:16:36 +1100 |
---|---|---|
committer | Dwight Watson <dwightwatson@me.com> | 2018-03-27 12:58:19 +1100 |
commit | 8e8f09fa187ad8b4567b68361e644a334741a7a0 (patch) | |
tree | 3dca02ef7a693d5d030dc013f1dbb377b5f4579f /activestorage/test/models | |
parent | 4c9c3ffc2e80155f31dbcf80591618ed1c858685 (diff) | |
download | rails-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/models')
-rw-r--r-- | activestorage/test/models/attachments_test.rb | 16 |
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? |