diff options
author | George Claghorn <george@basecamp.com> | 2018-05-28 16:28:46 -0400 |
---|---|---|
committer | George Claghorn <george@basecamp.com> | 2018-05-28 16:28:46 -0400 |
commit | 1bdaccc0b8cf8aac0dc833d6db14b9a902593ff5 (patch) | |
tree | 47c7fe84ded16a785feb86f42faa225175d4a8c4 /activestorage/test/models | |
parent | 34cc301f03aea2e579d6687a9ea9782afc1089a0 (diff) | |
download | rails-1bdaccc0b8cf8aac0dc833d6db14b9a902593ff5.tar.gz rails-1bdaccc0b8cf8aac0dc833d6db14b9a902593ff5.tar.bz2 rails-1bdaccc0b8cf8aac0dc833d6db14b9a902593ff5.zip |
Verify integrity after chunked download
Diffstat (limited to 'activestorage/test/models')
-rw-r--r-- | activestorage/test/models/blob_test.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/activestorage/test/models/blob_test.rb b/activestorage/test/models/blob_test.rb index a013b7a924..2d1857041d 100644 --- a/activestorage/test/models/blob_test.rb +++ b/activestorage/test/models/blob_test.rb @@ -84,7 +84,7 @@ class ActiveStorage::BlobTest < ActiveSupport::TestCase assert_equal "a" * 64.kilobytes, chunks.second end - test "open" do + test "open with integrity" do create_file_blob(filename: "racecar.jpg").open do |file| assert file.binmode? assert_equal 0, file.pos @@ -93,6 +93,16 @@ class ActiveStorage::BlobTest < ActiveSupport::TestCase end end + test "open without integrity" do + create_blob(data: "Hello, world!").tap do |blob| + blob.update! checksum: Digest::MD5.base64digest("Goodbye, world!") + + assert_raises ActiveStorage::IntegrityError do + blob.open { |file| flunk "Expected integrity check to fail" } + end + end + end + test "open in a custom tempdir" do tempdir = Dir.mktmpdir |