2016-10-15 08:23:12 +02:00
|
|
|
describe '/ticket/close' do
|
|
|
|
request('/user/logout')
|
|
|
|
Scripts.login($staff[:email], $staff[:password], true)
|
|
|
|
|
2018-07-17 06:17:49 +02:00
|
|
|
it 'should not close ticket if not assigned' do
|
|
|
|
ticket = $database.getRow('ticket', 1 , 'id')
|
|
|
|
request('/staff/un-assign-ticket', {
|
|
|
|
ticketNumber: ticket['ticket_number'],
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token
|
|
|
|
})
|
|
|
|
|
|
|
|
result = request('/ticket/close', {
|
|
|
|
ticketNumber: ticket['ticket_number'],
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token
|
|
|
|
})
|
|
|
|
|
|
|
|
(result['status']).should.equal('fail')
|
|
|
|
end
|
|
|
|
|
2018-07-17 06:22:00 +02:00
|
|
|
it 'should close ticket if you have it assigned' do
|
2016-10-15 08:23:12 +02:00
|
|
|
ticket = $database.getRow('ticket', 1 , 'id')
|
|
|
|
|
2018-07-17 06:17:49 +02:00
|
|
|
request('/staff/assign-ticket', {
|
|
|
|
ticketNumber: ticket['ticket_number'],
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token
|
|
|
|
})
|
|
|
|
|
2016-10-15 08:23:12 +02:00
|
|
|
result = request('/ticket/close', {
|
|
|
|
ticketNumber: ticket['ticket_number'],
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token
|
|
|
|
})
|
|
|
|
|
|
|
|
(result['status']).should.equal('success')
|
|
|
|
|
|
|
|
ticket = $database.getRow('ticket', 1 , 'id')
|
|
|
|
(ticket['closed']).should.equal('1')
|
2016-10-21 21:38:08 +02:00
|
|
|
(ticket['unread']).should.equal('1')
|
2016-10-15 08:23:12 +02:00
|
|
|
|
2016-12-29 21:25:45 +01:00
|
|
|
lastLog = $database.getLastRow('log')
|
2017-01-06 22:40:33 +01:00
|
|
|
(lastLog['type']).should.equal('CLOSE')
|
2018-07-17 06:17:49 +02:00
|
|
|
request('/staff/un-assign-ticket', {
|
|
|
|
ticketNumber: ticket['ticket_number'],
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token
|
|
|
|
})
|
2016-10-15 08:23:12 +02:00
|
|
|
end
|
2018-07-12 07:08:37 +02:00
|
|
|
|
2018-07-17 06:22:00 +02:00
|
|
|
it 'should close ticket if you are the author' do
|
|
|
|
request('/user/logout')
|
|
|
|
Scripts.createUser('closer@os4.com','closer','Closer')
|
|
|
|
Scripts.login('closer@os4.com','closer')
|
|
|
|
Scripts.createTicket('tickettoclose')
|
2018-07-12 07:08:37 +02:00
|
|
|
|
2018-07-17 06:22:00 +02:00
|
|
|
ticket = $database.getRow('ticket', 'tickettoclose', 'title')
|
2018-07-12 07:08:37 +02:00
|
|
|
|
2018-07-17 06:22:00 +02:00
|
|
|
result = request('/ticket/close', {
|
|
|
|
ticketNumber: ticket['ticket_number'],
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
(result['status']).should.equal('success')
|
|
|
|
|
|
|
|
ticket = $database.getRow('ticket', 'tickettoclose', 'title')
|
|
|
|
(ticket['closed']).should.equal('1')
|
2018-07-12 07:08:37 +02:00
|
|
|
|
2018-07-17 06:22:00 +02:00
|
|
|
lastLog = $database.getLastRow('log')
|
|
|
|
(lastLog['type']).should.equal('CLOSE')
|
2016-10-15 08:23:12 +02:00
|
|
|
end
|
2016-12-29 21:25:45 +01:00
|
|
|
end
|