From f66a69076f43617bacfe45961e229268ed15faa7 Mon Sep 17 00:00:00 2001 From: George Claghorn Date: Mon, 10 Jul 2017 16:17:48 -0400 Subject: Expose chunked downloads --- test/blob_test.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/blob_test.rb') diff --git a/test/blob_test.rb b/test/blob_test.rb index 60cf5426a8..cf27d59348 100644 --- a/test/blob_test.rb +++ b/test/blob_test.rb @@ -12,6 +12,19 @@ class ActiveStorage::BlobTest < ActiveSupport::TestCase assert_equal Digest::MD5.base64digest(data), blob.checksum end + test "download yields chunks" do + blob = create_blob data: 'a' * 75.kilobytes + chunks = [] + + blob.download do |chunk| + chunks << chunk + end + + assert_equal 2, chunks.size + assert_equal 'a' * 64.kilobytes, chunks.first + assert_equal 'a' * 11.kilobytes, chunks.second + end + test "urls expiring in 5 minutes" do blob = create_blob -- cgit v1.2.3 From 6dcdc5c9abb8e4e93a2c582b11ff4bb77d62ed3b Mon Sep 17 00:00:00 2001 From: Cristian Bica Date: Fri, 14 Jul 2017 01:09:56 +0300 Subject: Added rubocop / codeclimate config and fixed current offenses (#45) --- test/blob_test.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/blob_test.rb') diff --git a/test/blob_test.rb b/test/blob_test.rb index cf27d59348..6a9765a859 100644 --- a/test/blob_test.rb +++ b/test/blob_test.rb @@ -13,7 +13,7 @@ class ActiveStorage::BlobTest < ActiveSupport::TestCase end test "download yields chunks" do - blob = create_blob data: 'a' * 75.kilobytes + blob = create_blob data: "a" * 75.kilobytes chunks = [] blob.download do |chunk| @@ -21,8 +21,8 @@ class ActiveStorage::BlobTest < ActiveSupport::TestCase end assert_equal 2, chunks.size - assert_equal 'a' * 64.kilobytes, chunks.first - assert_equal 'a' * 11.kilobytes, chunks.second + assert_equal "a" * 64.kilobytes, chunks.first + assert_equal "a" * 11.kilobytes, chunks.second end test "urls expiring in 5 minutes" do -- cgit v1.2.3 From d0d4e33b86369e4b7c5656dd5db60e04f8c4d76e Mon Sep 17 00:00:00 2001 From: George Claghorn Date: Wed, 19 Jul 2017 13:58:23 -0400 Subject: Use descriptive new freeze_time helper --- test/blob_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/blob_test.rb') diff --git a/test/blob_test.rb b/test/blob_test.rb index 6a9765a859..ddc000ed51 100644 --- a/test/blob_test.rb +++ b/test/blob_test.rb @@ -28,7 +28,7 @@ class ActiveStorage::BlobTest < ActiveSupport::TestCase test "urls expiring in 5 minutes" do blob = create_blob - travel_to Time.now do + freeze_time do assert_equal expected_url_for(blob), blob.url assert_equal expected_url_for(blob, disposition: :attachment), blob.url(disposition: :attachment) end -- cgit v1.2.3