aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2017-07-01 14:25:02 +0200
committerDavid Heinemeier Hansson <david@loudthinking.com>2017-07-01 14:25:02 +0200
commit59d3e03b81d09c70fc1249514c1848e701757513 (patch)
treef8dbef32bbe70d6297b6bb1879cda55e56858a30 /test
parenta9d2ce5d18288223fce5a8095c2fb37520017828 (diff)
downloadrails-59d3e03b81d09c70fc1249514c1848e701757513.tar.gz
rails-59d3e03b81d09c70fc1249514c1848e701757513.tar.bz2
rails-59d3e03b81d09c70fc1249514c1848e701757513.zip
Uploading will set blob's byte size and checksum
Diffstat (limited to 'test')
-rw-r--r--test/blob_test.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/test/blob_test.rb b/test/blob_test.rb
index ad2df51ca9..04d636e189 100644
--- a/test/blob_test.rb
+++ b/test/blob_test.rb
@@ -5,8 +5,12 @@ require "active_file/blob"
ActiveFile::Blob.site = ActiveFile::Sites::DiskSite.new(File.join(Dir.tmpdir, "active_file"))
class ActiveFile::BlobTest < ActiveSupport::TestCase
- test "create after upload" do
- blob = ActiveFile::Blob.create_after_upload! data: StringIO.new("Hello world!"), filename: "hello.txt", content_type: "text/plain"
- assert_equal "Hello world!", blob.download
+ test "create after upload sets byte size and checksum" do
+ data = "Hello world!"
+ blob = ActiveFile::Blob.create_after_upload! data: StringIO.new(data), filename: "hello.txt", content_type: "text/plain"
+
+ assert_equal data, blob.download
+ assert_equal data.length, blob.byte_size
+ assert_equal Digest::MD5.hexdigest(data), blob.checksum
end
end