2017-08-12 08:32:15 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-07-09 12:31:27 -04:00
|
|
|
require "service/shared_service_tests"
|
|
|
|
|
|
|
|
class ActiveStorage::Service::ConfiguratorTest < ActiveSupport::TestCase
|
|
|
|
test "builds correct service instance based on service name" do
|
2018-01-16 20:32:02 -05:00
|
|
|
service = ActiveStorage::Service::Configurator.build(:foo, foo: { service: "Disk", root: "path" })
|
2017-07-09 16:21:14 -04:00
|
|
|
assert_instance_of ActiveStorage::Service::DiskService, service
|
2018-01-15 13:06:17 -05:00
|
|
|
assert_equal "path", service.root
|
2017-07-09 12:31:27 -04:00
|
|
|
end
|
|
|
|
|
2018-08-06 21:17:49 -04:00
|
|
|
test "builds correct service instance based on lowercase service name" do
|
|
|
|
service = ActiveStorage::Service::Configurator.build(:foo, foo: { service: "disk", root: "path" })
|
|
|
|
assert_instance_of ActiveStorage::Service::DiskService, service
|
|
|
|
assert_equal "path", service.root
|
|
|
|
end
|
|
|
|
|
2017-07-09 12:31:27 -04:00
|
|
|
test "raises error when passing non-existent service name" do
|
|
|
|
assert_raise RuntimeError do
|
2017-07-09 16:21:14 -04:00
|
|
|
ActiveStorage::Service::Configurator.build(:bigfoot, {})
|
2017-07-09 12:31:27 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|