diff --git a/server/libs/Controller.php b/server/libs/Controller.php
index 0f27fd28..402d76c8 100755
--- a/server/libs/Controller.php
+++ b/server/libs/Controller.php
@@ -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);
}
diff --git a/tests/system/disable-user-system.rb b/tests/system/disable-user-system.rb
index 210c45f5..81884ea8 100644
--- a/tests/system/disable-user-system.rb
+++ b/tests/system/disable-user-system.rb
@@ -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
diff --git a/tests/system/file-upload-download.rb b/tests/system/file-upload-download.rb
index 42da8593..b8ceef02 100644
--- a/tests/system/file-upload-download.rb
+++ b/tests/system/file-upload-download.rb
@@ -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
that contains images
',
+ '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