2016-09-09 05:38:58 +02:00
|
|
|
describe '/user/get' do
|
|
|
|
request('/user/logout')
|
|
|
|
Scripts.createUser('user_get@os4.com', 'user_get','User Get')
|
|
|
|
|
2016-12-01 19:07:11 +01:00
|
|
|
Scripts.login('user_get@os4.com', 'user_get')
|
2016-09-09 05:38:58 +02:00
|
|
|
result = request('/ticket/create', {
|
|
|
|
title: 'Should we pay?',
|
|
|
|
content: 'A Lannister always pays his debts.',
|
|
|
|
departmentId: 1,
|
2016-12-21 05:09:35 +01:00
|
|
|
language: 'en',
|
2016-09-09 05:38:58 +02:00
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token
|
|
|
|
})
|
2016-12-23 05:27:21 +01:00
|
|
|
|
2016-09-09 05:38:58 +02:00
|
|
|
@ticketNumber = result['data']['ticketNumber']
|
|
|
|
|
|
|
|
it 'should fail if not logged' do
|
|
|
|
request('/user/logout')
|
|
|
|
result = request('/user/get', {
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token
|
|
|
|
})
|
|
|
|
|
|
|
|
(result['status']).should.equal('fail')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should successfully return the ticket information' do
|
|
|
|
result = Scripts.login('user_get@os4.com', 'user_get')
|
|
|
|
$csrf_userid = result['userId']
|
|
|
|
$csrf_token = result['token']
|
|
|
|
result = request('/user/get', {
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token
|
|
|
|
})
|
|
|
|
|
|
|
|
ticket = $database.getRow('ticket', @ticketNumber, 'ticket_number')
|
|
|
|
|
|
|
|
(result['status']).should.equal('success')
|
|
|
|
(result['data']['name']).should.equal('User Get')
|
|
|
|
(result['data']['email']).should.equal('user_get@os4.com')
|
|
|
|
|
|
|
|
ticketFromUser = result['data']['tickets'][0]
|
|
|
|
(ticketFromUser['ticketNumber']).should.equal(ticket['ticket_number'])
|
|
|
|
(ticketFromUser['title']).should.equal(ticket['title'])
|
|
|
|
(ticketFromUser['content']).should.equal(ticket['content'])
|
|
|
|
(ticketFromUser['department']['id']).should.equal('1')
|
|
|
|
(ticketFromUser['department']['name']).should.equal($database.getRow('department', 1)['name'])
|
|
|
|
(ticketFromUser['date']).should.equal(ticket['date'])
|
|
|
|
(ticketFromUser['file']).should.equal(ticket['file'])
|
|
|
|
(ticketFromUser['language']).should.equal(ticket['language'])
|
|
|
|
(ticketFromUser['unread']).should.equal(false)
|
|
|
|
(ticketFromUser['author']['name']).should.equal('User Get')
|
|
|
|
(ticketFromUser['author']['email']).should.equal('user_get@os4.com')
|
2016-11-21 03:01:38 +01:00
|
|
|
(ticketFromUser['owner']).should.equal(nil)
|
2016-09-29 19:41:59 +02:00
|
|
|
(ticketFromUser['events']).should.equal([])
|
2016-09-09 05:38:58 +02:00
|
|
|
end
|
2016-12-23 05:27:21 +01:00
|
|
|
end
|