aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activestorage/lib/active_storage/service/configurator.rb4
-rw-r--r--activestorage/test/service/configurator_test.rb6
2 files changed, 9 insertions, 1 deletions
diff --git a/activestorage/lib/active_storage/service/configurator.rb b/activestorage/lib/active_storage/service/configurator.rb
index 39951fd026..32fa9105c6 100644
--- a/activestorage/lib/active_storage/service/configurator.rb
+++ b/activestorage/lib/active_storage/service/configurator.rb
@@ -26,7 +26,9 @@ module ActiveStorage
def resolve(class_name)
require "active_storage/service/#{class_name.to_s.underscore}_service"
- ActiveStorage::Service.const_get(:"#{class_name}Service")
+ ActiveStorage::Service.const_get(:"#{class_name.classify}Service")
+ rescue LoadError
+ raise "Missing service adapter for #{class_name.inspect}"
end
end
end
diff --git a/activestorage/test/service/configurator_test.rb b/activestorage/test/service/configurator_test.rb
index 1c9c5c3aa0..3ef9cf9fb6 100644
--- a/activestorage/test/service/configurator_test.rb
+++ b/activestorage/test/service/configurator_test.rb
@@ -9,6 +9,12 @@ class ActiveStorage::Service::ConfiguratorTest < ActiveSupport::TestCase
assert_equal "path", service.root
end
+ 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
+
test "raises error when passing non-existent service name" do
assert_raise RuntimeError do
ActiveStorage::Service::Configurator.build(:bigfoot, {})