2016-10-15 06:32:44 +02:00
|
|
|
describe '/ticket/change-department' do
|
|
|
|
request('/user/logout')
|
|
|
|
Scripts.login($staff[:email], $staff[:password], true)
|
|
|
|
|
2019-10-01 21:40:30 +02:00
|
|
|
Scripts.createTicket('Stafftitle','This ticket was made by an staff',1)
|
|
|
|
request('/user/logout')
|
|
|
|
|
|
|
|
request('/user/logout')
|
|
|
|
Scripts.login($staff[:email], $staff[:password], true)
|
|
|
|
|
2017-03-15 20:17:06 +01:00
|
|
|
request('/system/add-department', {
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token,
|
|
|
|
name: 'Suggestions'
|
|
|
|
})
|
|
|
|
request('/system/add-department', {
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token,
|
|
|
|
name: 'Tech support'
|
|
|
|
})
|
2019-10-01 21:40:30 +02:00
|
|
|
request('/system/add-department', {
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token,
|
|
|
|
name: 'Instalation problems'
|
|
|
|
})
|
2017-03-15 20:17:06 +01:00
|
|
|
request('/staff/edit', {
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token,
|
|
|
|
departments: '[1, 2, 3]',
|
|
|
|
staffId: 1
|
|
|
|
})
|
2016-10-15 06:32:44 +02:00
|
|
|
|
2019-10-01 21:40:30 +02:00
|
|
|
it 'should change department if staff has same department as ticket' do
|
|
|
|
|
|
|
|
request('/user/logout')
|
|
|
|
Scripts.login($staff[:email], $staff[:password], true)
|
2016-10-15 08:23:12 +02:00
|
|
|
ticket = $database.getRow('ticket', 1 , 'id')
|
2016-10-15 06:32:44 +02:00
|
|
|
|
|
|
|
result = request('/ticket/change-department', {
|
2016-10-15 08:23:12 +02:00
|
|
|
ticketNumber: ticket['ticket_number'],
|
2019-10-01 21:40:30 +02:00
|
|
|
departmentId: 4,
|
2016-10-15 06:32:44 +02:00
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token
|
|
|
|
})
|
|
|
|
|
|
|
|
(result['status']).should.equal('success')
|
|
|
|
|
|
|
|
ticket = $database.getRow('ticket', 1 , 'id')
|
2016-10-21 21:38:08 +02:00
|
|
|
(ticket['unread']).should.equal('1')
|
2019-10-01 21:40:30 +02:00
|
|
|
(ticket['department_id']).should.equal('4')
|
2016-12-29 21:25:45 +01:00
|
|
|
|
|
|
|
lastLog = $database.getLastRow('log')
|
2017-01-06 22:40:33 +01:00
|
|
|
(lastLog['type']).should.equal('DEPARTMENT_CHANGED')
|
2016-10-15 06:32:44 +02:00
|
|
|
end
|
2018-04-18 20:31:17 +02:00
|
|
|
|
|
|
|
it 'should unassing ticket if staff does not server new department' do
|
2019-10-01 21:40:30 +02:00
|
|
|
|
|
|
|
ticket = $database.getRow('ticket', 1 , 'id')
|
|
|
|
Scripts.assignTicket(ticket['ticket_number'])
|
|
|
|
request('/staff/edit', {
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token,
|
|
|
|
departments: '[2, 4]',
|
|
|
|
staffId: 1
|
|
|
|
})
|
|
|
|
|
|
|
|
result = request('/ticket/change-department', {
|
|
|
|
ticketNumber: ticket['ticket_number'],
|
|
|
|
departmentId: 3,
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token
|
|
|
|
})
|
|
|
|
|
|
|
|
(result['status']).should.equal('success')
|
|
|
|
|
|
|
|
ticket = $database.getRow('ticket', 1 , 'id')
|
|
|
|
(ticket['unread']).should.equal('1')
|
|
|
|
(ticket['department_id']).should.equal('3')
|
|
|
|
(ticket['owner_id']).should.equal(nil)
|
|
|
|
|
|
|
|
lastLog = $database.getLastRow('log')
|
|
|
|
(lastLog['type']).should.equal('DEPARTMENT_CHANGED')
|
|
|
|
|
|
|
|
end
|
|
|
|
it 'should change department if staff does not have ticket department and is author' do
|
|
|
|
|
|
|
|
ticket = $database.getRow('ticket', 'Stafftitle', 'title')
|
|
|
|
|
|
|
|
result = request('/ticket/change-department', {
|
|
|
|
ticketNumber: ticket['ticket_number'],
|
|
|
|
departmentId: 1,
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token
|
|
|
|
})
|
|
|
|
|
|
|
|
(result['status']).should.equal('success')
|
|
|
|
(ticket['department_id']).should.equal('1')
|
|
|
|
|
|
|
|
request('/staff/edit', {
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token,
|
|
|
|
departments: '[1, 2, 3]',
|
|
|
|
staffId: 1
|
|
|
|
})
|
2018-04-18 20:31:17 +02:00
|
|
|
end
|
2016-12-29 21:25:45 +01:00
|
|
|
end
|