aboutsummaryrefslogtreecommitdiffstats
path: root/test/controllers/direct_uploads_controller_test.rb
diff options
context:
space:
mode:
authorGeorge Claghorn <george.claghorn@gmail.com>2017-07-25 21:03:48 -0400
committerGitHub <noreply@github.com>2017-07-25 21:03:48 -0400
commit5492c4efa9d869f207ea702d0b328f26c047b75c (patch)
treefd875fe29ac0012dac6b4c22dfc5d0f9c0b243ec /test/controllers/direct_uploads_controller_test.rb
parent1907f465bc7a3385fa53fb2a2466372f96990615 (diff)
downloadrails-5492c4efa9d869f207ea702d0b328f26c047b75c.tar.gz
rails-5492c4efa9d869f207ea702d0b328f26c047b75c.tar.bz2
rails-5492c4efa9d869f207ea702d0b328f26c047b75c.zip
Add direct upload support to the disk service
Diffstat (limited to 'test/controllers/direct_uploads_controller_test.rb')
-rw-r--r--test/controllers/direct_uploads_controller_test.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/controllers/direct_uploads_controller_test.rb b/test/controllers/direct_uploads_controller_test.rb
index 8f309d0b28..76741d277e 100644
--- a/test/controllers/direct_uploads_controller_test.rb
+++ b/test/controllers/direct_uploads_controller_test.rb
@@ -61,3 +61,21 @@ if SERVICE_CONFIGURATIONS[:gcs]
else
puts "Skipping GCS Direct Upload tests because no GCS configuration was supplied"
end
+
+class ActiveStorage::DiskDirectUploadsControllerTest < ActionController::TestCase
+ setup do
+ @blob = create_blob
+ @routes = Routes
+ @controller = ActiveStorage::DirectUploadsController.new
+ end
+
+ test "creating new direct upload" do
+ post :create, params: { blob: {
+ filename: "hello.txt", byte_size: 6, checksum: Digest::MD5.base64digest("Hello"), content_type: "text/plain" } }
+
+ JSON.parse(@response.body).tap do |details|
+ assert_match /rails\/active_storage\/disk/, details["upload_to_url"]
+ assert_equal "hello.txt", ActiveStorage::Blob.find_signed(details["signed_blob_id"]).filename.to_s
+ end
+ end
+end