guillermo- path- staff-un-assign-ticket [skip ci]
This commit is contained in:
parent
5034ba71a3
commit
fd42574d15
|
@ -22,7 +22,7 @@ class UnAssignStaffController extends Controller {
|
|||
$user = Controller::getLoggedUser();
|
||||
$ticket = Ticket::getByTicketNumber($ticketNumber);
|
||||
|
||||
if($ticket->owner->id == $user->id) {
|
||||
if($ticket->owner && $ticket->owner->id == $user->id) {
|
||||
$user->sharedTicketList->remove($ticket);
|
||||
$user->store();
|
||||
$ticket->owner = null;
|
||||
|
|
|
@ -24,3 +24,4 @@ require './ticket/get.rb'
|
|||
require './ticket/custom-response.rb'
|
||||
require './staff/get.rb'
|
||||
require './staff/assign-ticket.rb'
|
||||
require './staff/un-assign-ticket.rb'
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
describe '/staff/un-assign-ticket' do
|
||||
request('/user/logout')
|
||||
Scripts.login($staff[:email], $staff[:password], true)
|
||||
|
||||
#TODO: Create a staff without the ticket
|
||||
|
||||
#it 'should fail if staff is not assign to the ticket'do
|
||||
|
||||
#end
|
||||
|
||||
it 'should un assign ticket if everything is okey' do
|
||||
ticket = $database.getRow('ticket', 1 , 'id')
|
||||
result = request('/staff/un-assign-ticket', {
|
||||
ticketNumber: ticket['ticket_number'],
|
||||
csrf_userid: $csrf_userid,
|
||||
csrf_token: $csrf_token
|
||||
})
|
||||
|
||||
(result['status']).should.equal('success')
|
||||
|
||||
ticket = $database.getRow('ticket', 1 , 'id')
|
||||
|
||||
(ticket['owner_id']).should.equal(nil)
|
||||
|
||||
staff_ticket = $database.getRow('staff_ticket', 1 , 'id')
|
||||
|
||||
(staff_ticket).should.equal(nil)
|
||||
end
|
||||
|
||||
it 'should fail if ticket is not yours' do
|
||||
ticket = $database.getRow('ticket', 1 , 'id')
|
||||
result = request('/staff/un-assign-ticket', {
|
||||
ticketNumber: ticket['ticket_number'],
|
||||
csrf_userid: $csrf_userid,
|
||||
csrf_token: $csrf_token
|
||||
})
|
||||
|
||||
(result['status']).should.equal('fail')
|
||||
(result['message']).should.equal('NO_PERMISSION')
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue