I'm hoping to get some clarification on the expected behavior surrounding
uploading the same file multiple times using ActiveStorage. Currently each
time the same file is uploaded a new ActiveStorage::Blob is created having
a unique key but a shared checksum. This behavior surprised me but I'm
wondering if this is a bug or intended behavior. The following test
illustrates how I was expecting AS to behave:
# activestorage/test/models/attachments_test.rb
test "attached blobs with same checksum are shared" do
@user.avatar.attach io: StringIO.new("STUFF"), filename: "town.jpg",
content_type: "image/jpg"
second_user = User.create!
second_user.avatar.attach io: StringIO.new("STUFF"), filename: "town.jpg",
content_type: "image/jpg"
assert_equal @user.avatar.blob.checksum, second_user.avatar.blob.checksum
assert_equal @user.avatar.blob, second_user.avatar.blob # currently fails
end
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.