fix ticket seen path and tests

This commit is contained in:
Guillermo Giuliana 2019-10-10 15:24:50 -03:00
parent 620cd6b876
commit 4b2d27e757
3 changed files with 8 additions and 5 deletions

View File

@ -44,7 +44,7 @@ class SeenController extends Controller {
$user = Controller::getLoggedUser();
$ticket = Ticket::getByTicketNumber($ticketnumber);
if(!$user->canManageTicket($this->ticket) && !$ticket->isAuthor($user)) {
if(!$user->canManageTicket($ticket) && !$ticket->isAuthor($user)) {
throw new RequestException(ERRORS::NO_PERMISSION);
}

View File

@ -25,6 +25,7 @@ require './user/edit-email.rb'
require './user/get.rb'
require './user/enable-disable.rb'
require './ticket/create.rb'
require './ticket/seen.rb'
require './ticket/comment.rb'
require './ticket/get.rb'
require './ticket/custom-response.rb'

View File

@ -2,10 +2,12 @@ describe '/ticket/seen' do
describe 'when a staff is logged' do
request('/user/logout')
Scripts.login($staff[:email], $staff[:password], true)
ticket = $database.getRow('ticket', 1, 'id')
Scripts.login($staff[:email], $staff[:password], true)
Scripts.assignTicket(ticket['ticket_number'])
it 'should change unread if everything is okey ' do
ticket = $database.getRow('ticket', 1, 'id')
result = request('/ticket/seen', {
ticketNumber: ticket['ticket_number'],
csrf_userid: $csrf_userid,
@ -13,7 +15,7 @@ describe '/ticket/seen' do
})
(result['status']).should.equal('success')
ticket = $database.getRow('ticket', 1, 'id')
(ticket['unreadStaff']).should.equal('0')
(ticket['unread_staff']).should.equal('0')
end
end
@ -21,7 +23,7 @@ describe '/ticket/seen' do
describe 'when an user is logged' do
request('/user/logout')
Scripts.login()
Scripts.login('user_get@os4.com', 'user_get')
it 'should change unread if everything is okey ' do
ticket = $database.getRow('ticket', 1, 'id')
result = request('/ticket/seen', {