2017-07-01 06:06:08 -04:00
|
|
|
require "bundler/setup"
|
|
|
|
require "active_support"
|
2017-07-04 12:10:53 -04:00
|
|
|
require "active_support/test_case"
|
2017-07-01 06:06:08 -04:00
|
|
|
require "active_support/testing/autorun"
|
|
|
|
require "byebug"
|
|
|
|
|
2017-07-06 05:33:29 -04:00
|
|
|
require "active_storage"
|
2017-07-09 12:03:13 -04:00
|
|
|
|
|
|
|
require "active_storage/service"
|
|
|
|
require "yaml"
|
|
|
|
SERVICE_CONFIGURATIONS = begin
|
|
|
|
YAML.load_file(File.expand_path("../service/configurations.yml", __FILE__)).deep_symbolize_keys
|
|
|
|
rescue Errno::ENOENT
|
|
|
|
puts "Missing service configuration file in test/service/configurations.yml"
|
|
|
|
{}
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2017-07-09 07:23:21 -04:00
|
|
|
require "active_storage/service/disk_service"
|
2017-07-09 16:22:20 -04:00
|
|
|
require "tmpdir"
|
|
|
|
ActiveStorage::Blob.service = ActiveStorage::Service::DiskService.new(root: Dir.mktmpdir("active_storage_tests"))
|
2017-07-09 11:04:28 -04:00
|
|
|
ActiveStorage::Service.logger = ActiveSupport::Logger.new(STDOUT)
|
2017-07-03 15:06:09 -04:00
|
|
|
|
2017-07-06 05:33:29 -04:00
|
|
|
require "active_storage/verified_key_with_expiration"
|
|
|
|
ActiveStorage::VerifiedKeyWithExpiration.verifier = ActiveSupport::MessageVerifier.new("Testing")
|
2017-07-04 12:10:53 -04:00
|
|
|
|
2017-07-11 12:53:17 -04:00
|
|
|
require "active_storage/variant"
|
|
|
|
ActiveStorage::Variant.verifier = ActiveSupport::MessageVerifier.new("Testing")
|
|
|
|
|
2017-07-04 12:10:53 -04:00
|
|
|
class ActiveSupport::TestCase
|
|
|
|
private
|
|
|
|
def create_blob(data: "Hello world!", filename: "hello.txt", content_type: "text/plain")
|
2017-07-06 05:33:29 -04:00
|
|
|
ActiveStorage::Blob.create_after_upload! io: StringIO.new(data), filename: filename, content_type: content_type
|
2017-07-04 12:10:53 -04:00
|
|
|
end
|
2017-07-05 09:18:50 -04:00
|
|
|
end
|
|
|
|
|
2017-07-21 16:50:36 -04:00
|
|
|
require "action_controller"
|
|
|
|
require "action_controller/test_case"
|
|
|
|
class ActionController::TestCase
|
|
|
|
Routes = ActionDispatch::Routing::RouteSet.new.tap do |routes|
|
|
|
|
routes.draw do
|
|
|
|
# FIXME: Hacky way to avoid having to instantiate the real engine
|
|
|
|
eval(File.readlines(File.expand_path("../../config/routes.rb", __FILE__)).slice(1..-2).join("\n"))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-07-06 05:33:29 -04:00
|
|
|
require "active_storage/attached"
|
|
|
|
ActiveRecord::Base.send :extend, ActiveStorage::Attached::Macros
|
2017-07-05 09:18:50 -04:00
|
|
|
|
|
|
|
require "global_id"
|
2017-07-06 05:33:29 -04:00
|
|
|
GlobalID.app = "ActiveStorageExampleApp"
|
2017-07-05 09:18:50 -04:00
|
|
|
ActiveRecord::Base.send :include, GlobalID::Identification
|
2017-07-09 16:22:20 -04:00
|
|
|
SignedGlobalID.verifier = ActiveStorage::VerifiedKeyWithExpiration.verifier
|