diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2017-07-04 17:34:37 +0200 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2017-07-04 17:34:37 +0200 |
commit | 7409bb2ff8e20f9036842a68f34e215cefdd98d9 (patch) | |
tree | 8788f9d2d89c519a71e837191e0172b02e274ffd /test/blob_test.rb | |
parent | 9b9d69b34ea77ee62bd0ef1846767db9f795c301 (diff) | |
download | rails-7409bb2ff8e20f9036842a68f34e215cefdd98d9.tar.gz rails-7409bb2ff8e20f9036842a68f34e215cefdd98d9.tar.bz2 rails-7409bb2ff8e20f9036842a68f34e215cefdd98d9.zip |
Actually #url needs to deal with the disposition
Diffstat (limited to 'test/blob_test.rb')
-rw-r--r-- | test/blob_test.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/test/blob_test.rb b/test/blob_test.rb index c726555dc6..45f6b5e3ba 100644 --- a/test/blob_test.rb +++ b/test/blob_test.rb @@ -12,16 +12,22 @@ class ActiveFile::BlobTest < ActiveSupport::TestCase assert_equal Digest::MD5.hexdigest(data), blob.checksum end - test "url expiring in 5 minutes" do + test "urls expiring in 5 minutes" do blob = create_blob travel_to Time.now do - assert_equal "/rails/blobs/#{ActiveFile::VerifiedKeyWithExpiration.encode(blob.key, expires_in: 5.minutes)}", blob.url + assert_equal expected_url_for(blob), blob.url + assert_equal expected_url_for(blob, disposition: :attachment), blob.url(disposition: :attachment) end end + private def create_blob(data: "Hello world!", filename: "hello.txt", content_type: "text/plain") ActiveFile::Blob.create_after_upload! io: StringIO.new(data), filename: filename, content_type: content_type end + + def expected_url_for(blob, disposition: :inline) + "/rails/blobs/#{ActiveFile::VerifiedKeyWithExpiration.encode(blob.key, expires_in: 5.minutes)}?disposition=#{disposition}" + end end |