I've looked at a ton of ways to do this, but haven't had any luck. Everything suggests using fixture_file_upload. So I'm using that in my tests. However when I look in the controller, the file's :tempfile is an array of strings which is the full content of the csv. However when I upload a file using postman the :tempfile is some sort of file object.
POST via test results in:
[1] pry(#<API::V1::ImportsController>)> params[:file]
=> <ActionController::Parameters {"content_type"=>"text/csv", "original_filename"=>"data_import.csv", "tempfile"=>["name, age\n", "bob, 4\n", "steve, 8\n", "mike, 9\n", "amy, 2\n", "nicole, 4\n"]} permitted: false>
POST via postman results in:
[1] pry(#<API::V1::ImportsController>)> params[:file]
=> #<ActionDispatch::Http::UploadedFile:0x007ffbe34b6e00
@content_type="text/csv",
@headers="Content-Disposition: form-data; name=\"file\"; filename=\"data_import.csv\"\r\nContent-Type: text/csv\r\n",
@original_filename="data_import.csv",
@tempfile=#<File:/var/folders/s5/0qnd62ld5pg3x7qq9my30cqm0000gn/T/RackMultipart20160324-62301-1gwxwy9.csv>>
Aucun commentaire:
Enregistrer un commentaire