Add test for image upload
This commit is contained in:
parent
03778f0e95
commit
4df3bab1ff
|
@ -147,6 +147,7 @@ abstract class Controller {
|
|||
}
|
||||
|
||||
public function replaceWithImagePaths($imagePaths, $content) {
|
||||
if(!is_array($imagePaths)) return $content;
|
||||
return str_replace(array_map(function($index) { return "IMAGE_PATH_$index"; }, array_keys($imagePaths)), $imagePaths, $content);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ describe'system/disable-user-system' do
|
|||
|
||||
numberOftickets= $database.query("SELECT * FROM ticket WHERE author_id IS NULL AND author_email IS NOT NULL AND author_name IS NOT NULL")
|
||||
|
||||
(numberOftickets.num_rows).should.equal(38)
|
||||
(numberOftickets.num_rows).should.equal(39)
|
||||
|
||||
request('/user/logout')
|
||||
|
||||
|
@ -93,7 +93,7 @@ describe'system/disable-user-system' do
|
|||
|
||||
numberOftickets= $database.query("SELECT * FROM ticket WHERE author_email IS NULL AND author_name IS NULL AND author_id IS NOT NULL" )
|
||||
|
||||
(numberOftickets.num_rows).should.equal(39)
|
||||
(numberOftickets.num_rows).should.equal(40)
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ describe 'File Upload and Download' do
|
|||
ticket = $database.getLastRow('ticket')
|
||||
|
||||
(ticket['file'].include? 'upload_3_.txt').should.equal(true)
|
||||
(ticket['file'].include? ('' + ticket['ticket_number'] + '_')).should.equal(true)
|
||||
(File.exist? ('../server/files/' + ticket['file'])).should.equal(true)
|
||||
end
|
||||
|
||||
|
@ -66,6 +67,7 @@ describe 'File Upload and Download' do
|
|||
})
|
||||
|
||||
user = $database.getRow('staff', $csrf_userid)
|
||||
(user['profile_pic'][0] == 'p').should.equal(true)
|
||||
|
||||
result = plainRequest('/system/download', {
|
||||
'csrf_userid' => $csrf_userid,
|
||||
|
@ -75,4 +77,29 @@ describe 'File Upload and Download' do
|
|||
|
||||
(result.body).should.include('file content')
|
||||
end
|
||||
|
||||
it 'should add images to ticket content when creating a new ticket' do
|
||||
request('/user/logout')
|
||||
Scripts.login('creator@os4.com', 'creator')
|
||||
|
||||
file = File.open( "../server/files/profile.jpg")
|
||||
|
||||
result = request('/ticket/create', {
|
||||
'csrf_userid' => $csrf_userid,
|
||||
'csrf_token' => $csrf_token,
|
||||
'title' => 'Ticket with file',
|
||||
'content' => 'this is a ticket <img src="IMAGE_PATH_0" /> that contains images <img src="IMAGE_PATH_1" />',
|
||||
'language' => 'en',
|
||||
'departmentId' => 1,
|
||||
'images' => 2,
|
||||
'image_0' => File.open( "../server/files/profile.jpg"),
|
||||
'image_1' => File.open( "../server/files/profile.jpg"),
|
||||
})
|
||||
|
||||
(result['status']).should.equal('success')
|
||||
|
||||
ticket = $database.getLastRow('ticket')
|
||||
|
||||
(ticket['content'].include? '_profile.jpg').should.equal(true)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue