From e64e3f14fd255d91ac0aa7a272741df08da82701 Mon Sep 17 00:00:00 2001 From: Dino Maric Date: Thu, 27 Jul 2017 22:15:38 +0200 Subject: Introduce the Dummy. (#70) --- test/controllers/direct_uploads_controller_test.rb | 36 ++++++++-------------- 1 file changed, 12 insertions(+), 24 deletions(-) (limited to 'test/controllers/direct_uploads_controller_test.rb') diff --git a/test/controllers/direct_uploads_controller_test.rb b/test/controllers/direct_uploads_controller_test.rb index 8c88befe6d..f15fcff314 100644 --- a/test/controllers/direct_uploads_controller_test.rb +++ b/test/controllers/direct_uploads_controller_test.rb @@ -1,14 +1,9 @@ require "test_helper" require "database/setup" -require "active_storage/direct_uploads_controller" - if SERVICE_CONFIGURATIONS[:s3] - class ActiveStorage::S3DirectUploadsControllerTest < ActionController::TestCase + class ActiveStorage::S3DirectUploadsControllerTest < ActionDispatch::IntegrationTest setup do - @routes = Routes - @controller = ActiveStorage::DirectUploadsController.new - @old_service = ActiveStorage::Blob.service ActiveStorage::Blob.service = ActiveStorage::Service.configure(:s3, SERVICE_CONFIGURATIONS) end @@ -18,10 +13,10 @@ if SERVICE_CONFIGURATIONS[:s3] 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" } } + post rails_direct_uploads_url, params: { blob: { + filename: "hello.txt", byte_size: 6, checksum: Digest::MD5.base64digest("Hello"), content_type: "text/plain" } } - JSON.parse(@response.body).tap do |details| + response.parsed_body.tap do |details| assert_match(/#{SERVICE_CONFIGURATIONS[:s3][:bucket]}\.s3.(\S+)?amazonaws\.com/, details["upload_to_url"]) assert_equal "hello.txt", ActiveStorage::Blob.find_signed(details["signed_blob_id"]).filename.to_s end @@ -32,10 +27,8 @@ else end if SERVICE_CONFIGURATIONS[:gcs] - class ActiveStorage::GCSDirectUploadsControllerTest < ActionController::TestCase + class ActiveStorage::GCSDirectUploadsControllerTest < ActionDispatch::IntegrationTest setup do - @routes = Routes - @controller = ActiveStorage::DirectUploadsController.new @config = SERVICE_CONFIGURATIONS[:gcs] @old_service = ActiveStorage::Blob.service @@ -47,10 +40,10 @@ if SERVICE_CONFIGURATIONS[:gcs] 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" } } + post rails_direct_uploads_url, params: { blob: { + filename: "hello.txt", byte_size: 6, checksum: Digest::MD5.base64digest("Hello"), content_type: "text/plain" } } - JSON.parse(@response.body).tap do |details| + @response.parsed_body.tap do |details| assert_match %r{storage\.googleapis\.com/#{@config[:bucket]}}, details["upload_to_url"] assert_equal "hello.txt", ActiveStorage::Blob.find_signed(details["signed_blob_id"]).filename.to_s end @@ -60,17 +53,12 @@ else puts "Skipping GCS Direct Upload tests because no GCS configuration was supplied" end -class ActiveStorage::DiskDirectUploadsControllerTest < ActionController::TestCase - setup do - @routes = Routes - @controller = ActiveStorage::DirectUploadsController.new - end - +class ActiveStorage::DiskDirectUploadsControllerTest < ActionDispatch::IntegrationTest 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" } } + post rails_direct_uploads_url, params: { blob: { + filename: "hello.txt", byte_size: 6, checksum: Digest::MD5.base64digest("Hello"), content_type: "text/plain" } } - JSON.parse(@response.body).tap do |details| + @response.parsed_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 -- cgit v1.2.3