Testing 'create' from multipart/form-data submission

good morning forum! :slight_smile:

i’m looking to test the creation of a record from the submission of a
form with content-type=“multipart/form-data” (uploading an image into a
BLOB field), currently i’m using a small binary string to simulate this
but for thoroughness i want to provide the test with a path to an image
on my filesystem and have it populate the db correctly…any idea what
the syntax for posting a form this way is?? (current code below)

def test_create
num_images = Image.count

	{:image => {
         'item_id' => 203,
	     'primary_image' => 0,
         'data_orig' => '01010101',
	     'data_medium' => '01010101',
	     'data_thumb' => '01010101',
	     'content_type' => 'image/jpg',
	     'comment' => 'this is a comment'}})

assert_response( :redirect )
assert_redirected_to :action => 'list'
assert_equal num_images + 1, Image.count


many thanks, Marcus

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs