1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix mocking test to mock kwargs

This commit is contained in:
Akira Matsuda 2019-09-06 18:50:14 +09:00
parent dea19d4ead
commit 855de1a700

View file

@ -42,7 +42,7 @@ class ActiveStorage::OneAttachedTest < ActiveSupport::TestCase
test "attaching a new blob from a Hash to an existing record passes record" do
hash = { io: StringIO.new("STUFF"), filename: "town.jpg", content_type: "image/jpg" }
blob = ActiveStorage::Blob.build_after_unfurling(hash)
blob = ActiveStorage::Blob.build_after_unfurling(**hash)
arguments = [hash.merge(record: @user)]
assert_called_with(ActiveStorage::Blob, :build_after_unfurling, arguments, returns: blob) do
@user.avatar.attach hash
@ -59,9 +59,9 @@ class ActiveStorage::OneAttachedTest < ActiveSupport::TestCase
def upload.open
@io ||= StringIO.new("")
end
arguments = [io: upload.open, filename: upload.original_filename, content_type: upload.content_type, record: @user]
blob = ActiveStorage::Blob.build_after_unfurling(*arguments)
assert_called_with(ActiveStorage::Blob, :build_after_unfurling, arguments, returns: blob) do
arguments = { io: upload.open, filename: upload.original_filename, content_type: upload.content_type, record: @user }
blob = ActiveStorage::Blob.build_after_unfurling(**arguments)
assert_called_with(ActiveStorage::Blob, :build_after_unfurling, [arguments], returns: blob) do
@user.avatar.attach upload
end
end