diff options
author | George Claghorn <george@basecamp.com> | 2018-05-17 19:14:11 -0400 |
---|---|---|
committer | George Claghorn <george@basecamp.com> | 2018-05-17 19:14:11 -0400 |
commit | 9f95767979579f5761cb0d2bcccb67f3662349c5 (patch) | |
tree | 9375eeeeff7d494e2dcf0b206e89ea892cb21f4a /activestorage/test | |
parent | f018d4e118f34fd9b54ad45771ed575936678158 (diff) | |
download | rails-9f95767979579f5761cb0d2bcccb67f3662349c5.tar.gz rails-9f95767979579f5761cb0d2bcccb67f3662349c5.tar.bz2 rails-9f95767979579f5761cb0d2bcccb67f3662349c5.zip |
Permit opening a blob in a custom tempdir
Diffstat (limited to 'activestorage/test')
-rw-r--r-- | activestorage/test/models/blob_test.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activestorage/test/models/blob_test.rb b/activestorage/test/models/blob_test.rb index 1bc5951d79..a013b7a924 100644 --- a/activestorage/test/models/blob_test.rb +++ b/activestorage/test/models/blob_test.rb @@ -93,6 +93,18 @@ class ActiveStorage::BlobTest < ActiveSupport::TestCase end end + test "open in a custom tempdir" do + tempdir = Dir.mktmpdir + + create_file_blob(filename: "racecar.jpg").open(tempdir: tempdir) do |file| + assert file.binmode? + assert_equal 0, file.pos + assert_match(/\.jpg\z/, file.path) + assert file.path.starts_with?(tempdir) + assert_equal file_fixture("racecar.jpg").binread, file.read, "Expected downloaded file to match fixture file" + end + end + test "urls expiring in 5 minutes" do blob = create_blob |