guillermo- path- staff-get-ticket [skip ci]

This commit is contained in:
ivan 2016-10-14 21:59:11 -03:00
parent a42e00ad9b
commit 59099a3bbf
4 changed files with 47 additions and 0 deletions

View File

@ -2,6 +2,7 @@
require_once 'staff/get.php';
require_once 'staff/assign-ticket.php';
require_once 'staff/un-assign-ticket.php';
require_once 'staff/get-tickets.php';
$systemControllerGroup = new ControllerGroup();
$systemControllerGroup->setGroupPath('/staff');
@ -9,5 +10,6 @@ $systemControllerGroup->setGroupPath('/staff');
$systemControllerGroup->addController(new GetStaffController);
$systemControllerGroup->addController(new AssignStaffController);
$systemControllerGroup->addController(new UnAssignStaffController);
$systemControllerGroup->addController(new GetTicketStaffController);
$systemControllerGroup->finalize();

View File

@ -0,0 +1,18 @@
<?php
use Respect\Validation\Validator as DataValidator;
class GetTicketStaffController extends Controller {
const PATH = '/get-tickets';
public function validations() {
return [
'permission' => 'staff_1',
'requestData' => []
];
}
public function handler() {
$user = Controller::getLoggedUser();
Response::respondSuccess($user->sharedTicketList->toArray());
}
}

View File

@ -25,3 +25,4 @@ require './ticket/custom-response.rb'
require './staff/get.rb'
require './staff/assign-ticket.rb'
require './staff/un-assign-ticket.rb'
require './staff/get-tickets.rb'

View File

@ -0,0 +1,26 @@
describe '/staff/get-tickets' do
request('/user/logout')
Scripts.login($staff[:email], $staff[:password], true)
it 'should get ticket list' do
ticket = $database.getRow('ticket', 1 , 'id')
request('/staff/assign-ticket', {
ticketNumber: ticket['ticket_number'],
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
ticket = $database.getRow('ticket', 2 , 'id')
request('/staff/assign-ticket', {
ticketNumber: ticket['ticket_number'],
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
result = request('/staff/get-tickets', {
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
(result['status']).should.equal('success')
end
end