I’m successfully able to upload images using fixtures and the TestData module from the documentation when using Rails’ system tests (Rails 5.2). However, whenever the Selenium browser opens up, all the uploaded test images have broken links. The files all exist locally and were uploaded using
Shrine::Storage::FileSystem.new('tmp/uploads'). Any thoughts on why the links are broken?
The image file exists at
/Users/me/projects/test_app/tmp/uploads/ac220637db69c0348120bff043b50a84 but when I copy and visit the full URL at
http://127.0.0.1:51108/Users/me/projects/test_app/tmp/uploads/ac220637db69c0348120bff043b50a84 it redirects me back to the page instead of the image file.
In order to get my fixture .yml file to properly load the TestData image url, I had to do the following:
image_data: > <%= TestData.image_data %>
otherwise, there is a JSON parsing error and Rails will add
--- to the beginning of the JSON image data. Perhaps the testing documentation should be updated unless this is only a Rails 5.2 bug.