From 69d0c581722a8cdb72dd7c5caa0bbd2cba4a35c1 Mon Sep 17 00:00:00 2001 From: Guillermo Date: Mon, 1 Jul 2019 20:38:34 -0300 Subject: [PATCH] fix test ruby --- server/controllers/system/email-polling.php | 2 +- server/controllers/ticket/comment.php | 14 +++++++------- server/controllers/ticket/edit-comment.php | 1 + tests/scripts.rb | 7 +++++++ tests/ticket/edit-comment.rb | 9 ++++++--- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/server/controllers/system/email-polling.php b/server/controllers/system/email-polling.php index e9508da1..f4ae3c0c 100755 --- a/server/controllers/system/email-polling.php +++ b/server/controllers/system/email-polling.php @@ -30,7 +30,7 @@ class EmailPollingController extends Controller { throw new RequestException(ERRORS::INVALID_TOKEN); if(Controller::isUserSystemEnabled()) - throw new RequestException(ERRORS::USER_SYSTEM); + throw new RequestException(ERRORS::USER_SYSTEM_ENABLED); $this->mailbox = new \PhpImap\Mailbox( Setting::getSetting('imap-host')->getValue(), diff --git a/server/controllers/ticket/comment.php b/server/controllers/ticket/comment.php index c446b809..1780a44e 100755 --- a/server/controllers/ticket/comment.php +++ b/server/controllers/ticket/comment.php @@ -95,7 +95,7 @@ class CommentController extends Controller { 'staff' => true ]); } else if($isOwner) { - $this->sendMail($ticketAuthor); + !Controller::request('private') ? $this->sendMail($ticketAuthor) : null; } Log::createLog('COMMENT', $this->ticket->ticketNumber); @@ -151,12 +151,12 @@ class CommentController extends Controller { } $mailSender->setTemplate(MailTemplate::TICKET_RESPONDED, [ - 'to' => $email, - 'name' => $name, - 'title' => $this->ticket->title, - 'ticketNumber' => $this->ticket->ticketNumber, - 'content' => $this->content, - 'url' => $url + 'to' => $email, + 'name' => $name, + 'title' => $this->ticket->title, + 'ticketNumber' => $this->ticket->ticketNumber, + 'content' => $this->content, + 'url' => $url ]); $mailSender->send(); diff --git a/server/controllers/ticket/edit-comment.php b/server/controllers/ticket/edit-comment.php index 3259ee0c..5184192a 100644 --- a/server/controllers/ticket/edit-comment.php +++ b/server/controllers/ticket/edit-comment.php @@ -62,6 +62,7 @@ class EditCommentController extends Controller { $ticket->store(); } + Response::respondSuccess(); } } diff --git a/tests/scripts.rb b/tests/scripts.rb index ff92b8d5..15b58d95 100644 --- a/tests/scripts.rb +++ b/tests/scripts.rb @@ -115,6 +115,13 @@ class Scripts color: color }) end + def self.assignTicket(ticketnumber) + request('/staff/assign-ticket', { + ticketNumber: ticketnumber, + csrf_userid: $csrf_userid, + csrf_token: $csrf_token + }) + end def self.commentTicket(ticketnumber,content) request('/ticket/comment', { content: content, diff --git a/tests/ticket/edit-comment.rb b/tests/ticket/edit-comment.rb index f0df57c4..585f03ca 100644 --- a/tests/ticket/edit-comment.rb +++ b/tests/ticket/edit-comment.rb @@ -71,12 +71,15 @@ describe '/ticket/edit-comment' do it 'should not change the content of a comment if the user is not the author' do + request('/user/logout') Scripts.login($staff[:email], $staff[:password], true) ticket = $database.getRow('ticket', 'ticket made by an user', 'title') - Scripts.commentTicket(ticket['ticket_number'],'comment by a staffffff') - ticketevent = $database.getRow('ticketevent', 'comment by a staffffff', 'content') + Scripts.assignTicket(ticket['ticket_number']) + Scripts.commentTicket(ticket['ticket_number'],'this is a new comment of a staff member') + + ticketevent = $database.getRow('ticketevent', 'this is a new comment of a staff member', 'content') request('/user/logout') Scripts.login(); @@ -84,7 +87,7 @@ describe '/ticket/edit-comment' do result = request('/ticket/edit-comment', { csrf_userid: $csrf_userid, csrf_token: $csrf_token, - content: 'comment edited by a user', + content: 'comment edited by an user', ticketEventId: ticketevent['id'] }) (result['status']).should.equal('fail')