Marcus Mitchell
2006-Jan-12 11:16 UTC
[Rails] Testing ''create'' from multipart/form-data submission
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
post(:create,
{: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
end
many thanks, Marcus
--
Posted via http://www.ruby-forum.com/.
