aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/test/service/configurator_test.rb
blob: 0a79b37aa4b51b3c8d1a799009afcbf2d70a30d0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

require "service/shared_service_tests"

class ActiveStorage::Service::ConfiguratorTest < ActiveSupport::TestCase
  test "builds correct service instance based on service name" do
    service = ActiveStorage::Service::Configurator.build(:foo, foo: { service: "Disk", root: "path", host: "http://localhost:3000" })

    assert_instance_of ActiveStorage::Service::DiskService, service
    assert_equal "path", service.root
    assert_equal "http://localhost:3000", service.host
  end

  test "raises error when passing non-existent service name" do
    assert_raise RuntimeError do
      ActiveStorage::Service::Configurator.build(:bigfoot, {})
    end
  end
end