
Question:
I have a case where I want to test a file upload but I'm having problems breaking a circle of pain.
We are checking that the file uploaded is a CSV file, so the file should have the extention .csv.
To test we need to use ActionDispatch::TestProcess.fixture_file_upload and we place the test file in the test/fixtures/files diectory.
Now when I try to run a test, Rails sees this csv file in the sub-folder of fixtures and thinks it should use the file to populate some table. Which is wrong.
Is there any way I can tell Rails not to try and use this file for populating a table?
- I can't rename the extension as that is what I'm trying to test.
- I can't move the file out of fixtures as then the fixture_file_upload won't work
- I can't seem to tell Rails to leave this file alone when populating fixture data.
:(
Solution:1
Well the answer I've come up with so far is to move the files out of fixtures directory and to place the equivalent of "../" at the start of the filename (in the fixture_file_upload parameter) to make it backdown a level.
Not exactly a good fix, so would still like to hear if it's possible to tell Rails not to load the csv file as table data.
Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
EmoticonEmoticon