opensupports/tests/staff/un-assign-ticket.rb

84 lines
2.6 KiB
Ruby
Raw Normal View History

describe '/staff/un-assign-ticket' do
2018-04-18 20:31:17 +02:00
Scripts.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
2018-03-12 23:31:54 +01:00
it 'should unassign ticket if it is the current owner' 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)
2016-10-21 21:38:08 +02:00
(ticket['unread']).should.equal('1')
2018-07-19 23:09:54 +02:00
staff_ticket = $database.getRow('staff_ticket', 1 , 'ticket_id')
(staff_ticket).should.equal(nil)
end
2018-04-18 20:31:17 +02:00
it 'should fail if ticket is not yours and you are a staff level 1' do
$database.query('update staff set level="1" where id="1";')
ticket = $database.getRow('ticket', 1 , 'id')
Scripts.logout()
Scripts.login('ayra2@opensupports.com', 'starkpassword', true)
result = request('/staff/assign-ticket', {
2018-03-12 23:31:54 +01:00
ticketNumber: ticket['ticket_number'],
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
2018-04-18 20:31:17 +02:00
})
(result['status']).should.equal('success')
ticket = $database.getRow('ticket', 1 , 'id')
Scripts.logout()
Scripts.login($staff[:email], $staff[:password], true)
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')
$database.query('update staff set level="3" where id="1";')
end
it 'should unassign ticket if you are a staff level 3' do
ticket = $database.getRow('ticket', 1 , 'id')
2018-03-12 23:31:54 +01:00
Scripts.logout()
Scripts.login($staff[:email], $staff[:password], true)
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)
(ticket['unread']).should.equal('1')
2018-07-19 23:09:54 +02:00
staff_ticket = $database.getRow('staff_ticket', 1 , 'ticket_id')
2018-03-12 23:31:54 +01:00
(staff_ticket).should.equal(nil)
end
2018-03-09 19:17:28 +01:00
end