[ruby-it] rails integration test e file upload: come?
Luca Mearelli
luca.mearelli a gmail.com
Dom 16 Dic 2007 17:49:29 CET
On Dec 16, 2007 10:29 AM, gabriele renzi <surrender_it a yahoo.it> wrote:
> il fatto è che non sto facendo un test unitario, ma di
> integrazione.
(forse.. non ho provato) con:
def MyTestUploadedFile < ActionController::TestUploadedFile
def to_s
self
end
end
# Shortcut for ActionController::TestUploadedFile.new(Test::Unit::TestCase.fixture_path
+ path, type). Example:
# post :change_avatar, :avatar =>
fixture_file_upload('/files/spongebob.png', 'image/png')
def my_fixture_file_upload(path, mime_type = nil)
MyTestUploadedFile.new(
Test::Unit::TestCase.respond_to?(:fixture_path) ?
Test::Unit::TestCase.fixture_path + path : path,
mime_type
)
end
potresti poi fare:
data = my_fixture_file_upload('rails.png', 'image/png')
post 'action', :data=>data
(magari hai gia provato e non funziona....)
ciao,
Luca
Maggiori informazioni sulla lista
Ml