Env Rails: 5.1.3
Ruby: 2.3.1p112Rails test de 5 l'intégration convertit fixture_file_upload à chaîne
Contexte
J'ai un test d'intégration de base comme suit:
class MerchandisesControllerTest < ActionDispatch::IntegrationTest
def test_successful_create
post org_merchandises_path(org, merchandise: merchandise_params)
...
end
def merchandise_params
{
description: 'Get swole fast.',
name: 'Foo Powder',
price: 50,
images_attributes: {
'0' => {
image: fixture_file_upload('files/image.png', 'image/png'),
primary: true,
}
}
}
end
end
Lorsque je lance le test, le paramètre image est converti en String
:
# Inside MerchandisesController#create
params.dig(:merchandise, :images_attributes, '0', :image)
=> "#<Rack::Test::UploadedFile:0x007fbdc9520b00>"
# This is a String, but should instance of ActionDispatch::Http::UploadedFile
possibles Problèmes liés
https://github.com/rails/rails/issues/28129