2016-10-20 23:34:06 +02:00
|
|
|
describe '/ticket/seen' do
|
|
|
|
|
|
|
|
describe 'when a staff is logged' do
|
2021-11-05 21:06:08 +01:00
|
|
|
Scripts.logout()
|
2021-09-22 23:20:19 +02:00
|
|
|
ticket = $database.getRow('ticket', 'Should we pay?', 'title')
|
2016-10-20 23:34:06 +02:00
|
|
|
|
2019-10-10 20:24:50 +02:00
|
|
|
Scripts.login($staff[:email], $staff[:password], true)
|
|
|
|
Scripts.assignTicket(ticket['ticket_number'])
|
2016-10-20 23:34:06 +02:00
|
|
|
it 'should change unread if everything is okey ' do
|
2019-10-10 20:24:50 +02:00
|
|
|
|
2016-10-20 23:34:06 +02:00
|
|
|
result = request('/ticket/seen', {
|
|
|
|
ticketNumber: ticket['ticket_number'],
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token
|
|
|
|
})
|
|
|
|
(result['status']).should.equal('success')
|
2021-09-22 23:20:19 +02:00
|
|
|
ticket = $database.getRow('ticket', 'Should we pay?', 'title')
|
2020-05-13 07:51:51 +02:00
|
|
|
(ticket['unread_staff']).should.equal(0)
|
2016-10-21 21:38:08 +02:00
|
|
|
|
2016-10-20 23:34:06 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-09-28 02:19:34 +02:00
|
|
|
describe 'when an user is logged' do
|
2019-10-10 23:22:04 +02:00
|
|
|
|
2021-11-05 21:06:08 +01:00
|
|
|
Scripts.logout()
|
2019-10-10 23:22:04 +02:00
|
|
|
Scripts.login()
|
|
|
|
it 'should fail if user is not author' do
|
2021-09-22 23:20:19 +02:00
|
|
|
ticket = $database.getRow('ticket', 'Should we pay?', 'title')
|
2019-10-10 23:22:04 +02:00
|
|
|
result = request('/ticket/seen', {
|
|
|
|
ticketNumber: ticket['ticket_number'],
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token
|
|
|
|
})
|
|
|
|
|
|
|
|
(result['status']).should.equal('fail')
|
|
|
|
(result['message']).should.equal('NO_PERMISSION')
|
|
|
|
end
|
2016-10-20 23:34:06 +02:00
|
|
|
|
2021-11-05 21:06:08 +01:00
|
|
|
Scripts.logout()
|
2019-10-10 20:24:50 +02:00
|
|
|
Scripts.login('user_get@os4.com', 'user_get')
|
2016-10-20 23:34:06 +02:00
|
|
|
it 'should change unread if everything is okey ' do
|
2021-09-22 23:20:19 +02:00
|
|
|
ticket = $database.getRow('ticket', 'Should we pay?', 'title')
|
2016-10-21 21:38:08 +02:00
|
|
|
result = request('/ticket/seen', {
|
|
|
|
ticketNumber: ticket['ticket_number'],
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token
|
|
|
|
})
|
2016-10-20 23:34:06 +02:00
|
|
|
|
2016-10-21 21:38:08 +02:00
|
|
|
(result['status']).should.equal('success')
|
2021-09-22 23:20:19 +02:00
|
|
|
ticket = $database.getRow('ticket', 'Should we pay?', 'title')
|
2020-05-13 07:51:51 +02:00
|
|
|
(ticket['unread']).should.equal(0)
|
2016-10-20 23:34:06 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-09-28 02:19:34 +02:00
|
|
|
end
|