Ask A Question

Notifications

You’re not receiving notifications from this thread.

Testing File Uploads in Rails with Shrine Discussion

This is great! Can we add system tests too? How can we write a system test to create photo and update photos?

Reply

Here's how I'd system test

"""
class PhotosTest < ApplicationSystemTestCase
test "create" do
visit new_photos_url
attach_file("photos_image", "test/fixtures/files/test.png")
click_on "Create Photo"
assert_equal 'test.png', JSON.parse(Photo.last.image_data)['metadata']['filename']
end
end
"""

Reply

Hey Chris! Great work as always! It's not that is hard to be honest, but I think it would be great and mostly helpful to have in the description of the video any previous related episode to this one. In that way, we can simply watch it beforehand, without having to look for it ourselves.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,946+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.