Forum: Ruby on Rails Testing 'create' from multipart/form-data submission

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Marcus M. (Guest)
on 2006-01-12 13:16
good morning forum! :)

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 topic is locked and can not be replied to.