Raise an ArgumentError instead of a RuntimeError

This commit is contained in:
George Claghorn 2018-07-08 11:35:27 -04:00
parent 79edcaeb6c
commit 0b85123cd8
3 changed files with 3 additions and 3 deletions

View File

@ -58,7 +58,7 @@ module ActiveStorage
when String
ActiveStorage::Blob.find_signed(attachable)
else
raise "Could not find or build blob: expected attachable, got #{attachable.inspect}"
raise ArgumentError, "Could not find or build blob: expected attachable, got #{attachable.inspect}"
end
end
end

View File

@ -253,7 +253,7 @@ class ActiveStorage::ManyAttachedTest < ActiveSupport::TestCase
end
test "creating a record with an unexpected object attached" do
error = assert_raises { User.create!(name: "Jason", highlights: :foo) }
error = assert_raises(ArgumentError) { User.create!(name: "Jason", highlights: :foo) }
assert_equal "Could not find or build blob: expected attachable, got :foo", error.message
end

View File

@ -255,7 +255,7 @@ class ActiveStorage::OneAttachedTest < ActiveSupport::TestCase
end
test "creating a record with an unexpected object attached" do
error = assert_raises { User.create!(name: "Jason", avatar: :foo) }
error = assert_raises(ArgumentError) { User.create!(name: "Jason", avatar: :foo) }
assert_equal "Could not find or build blob: expected attachable, got :foo", error.message
end