guillermo - add asign staff ticket [skip ci]

This commit is contained in:
ivan 2016-10-07 20:32:22 -03:00
parent db97ee09b7
commit dcea795f89
2 changed files with 46 additions and 0 deletions

View File

@ -23,3 +23,4 @@ require './ticket/comment.rb'
require './ticket/get.rb'
require './ticket/custom-response.rb'
require './staff/get.rb'
require './staff/assign-ticket.rb'

View File

@ -0,0 +1,45 @@
describe '/staff/assign-ticket' do
request('/user/logout')
Scripts.login($staff[:email], $staff[:password], true)
#TODO: Create a staff without all department
#it 'should fail if staff is not in the same department'do
#end
it 'should assign ticket if everything is okey' do
ticket = $database.getRow('ticket', 1 , 'id')
result = request('/staff/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('1')
staff_ticket = $database.getRow('staff_ticket', 1 , 'id')
(staff_ticket['staff_id']).should.equal('1')
(staff_ticket['ticket_id']).should.equal('1')
end
it 'should fail if ticket is already owned' do
ticket = $database.getRow('ticket', 1 , 'id')
result = request('/staff/assign-ticket', {
ticketNumber: ticket['ticket_number'],
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
(result['status']).should.equal('fail')
(result['message']).should.equal('TICKET_ALREADY_ASSIGNED')
end
end