Raise an ArgumentError instead of a RuntimeError
This commit is contained in:
parent
79edcaeb6c
commit
0b85123cd8
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue