Testing an Uploaded Image With RSpec

July 17th, 2016

I had some initial difficulty testing my photos controller with an uploaded file for the :image field, because the test was reading :image as nil. What worked was wrapping the image in a content wrapper using Class: Rack::Test::UploadedFile. I have this implemented in my factory: image { Rack::Test::UploadedFile.new(File.open(File.join(Rails.root, ‘/spec/support/my_image.jpg’)), ‘image/jpeg’) } The image file “my_image.jpg” […]

Customizing Strong Parameters

July 10th, 2016

I’m working on a Rails app to allow users to post information on places they want to go to and then add the places to their personal bucket lists. While the strong parameters for the create and update actions can commonly be shared, I wanted to set different permitted parameters for the create and update […]

More Results