added test for upload

This commit is contained in:
Alexey Verkhovsky 2005-01-23 14:32:10 +00:00
parent 44eea43940
commit 14c114529a

View file

@ -11,6 +11,7 @@ class FileControllerTest < Test::Unit::TestCase
FILE_AREA = RAILS_ROOT + '/storage/test/wiki1' FILE_AREA = RAILS_ROOT + '/storage/test/wiki1'
FileUtils.mkdir_p(FILE_AREA) unless File.directory?(FILE_AREA) FileUtils.mkdir_p(FILE_AREA) unless File.directory?(FILE_AREA)
FileUtils.rm(Dir["#{FILE_AREA}/*"])
def setup def setup
setup_test_wiki setup_test_wiki
@ -64,4 +65,18 @@ class FileControllerTest < Test::Unit::TestCase
assert_rendered_file 'file/file' assert_rendered_file 'file/file'
end end
def test_pic_upload_end_to_end
# rails-e2e.gif is unknown to the system
r = process 'pic', 'web' => 'wiki1', 'id' => 'rails-e2e.gif'
assert_success
assert_rendered_file 'file/file'
# User uploads the picture
picture = File.read("#{RAILS_ROOT}/test/fixtures/rails.gif")
r = process 'pic', 'web' => 'wiki1', 'id' => 'rails-e2e.gif', 'file' => StringIO.new(picture)
assert_redirect_url '/'
assert @wiki.file_yard(@web).has_file?('rails-e2e.gif')
assert_equal(picture, File.read("#{RAILS_ROOT}/storage/test/wiki1/rails-e2e.gif"))
end
end end