opensupports/tests/user/get.rb

59 lines
2.3 KiB
Ruby
Raw Normal View History

describe '/user/get' do
Scripts.logout()
Scripts.createUser('user_get@os4.com', 'user_get','User Get')
Scripts.login('user_get@os4.com', 'user_get')
result = request('/ticket/create', {
title: 'Should we pay?',
content: 'A Lannister always pays his debtssss.',
departmentId: 1,
language: 'en',
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
ticket = $database.getRow('ticket', 'A Lannister always pays his debtssss.' , 'content')
@ticketNumber = ticket['ticket_number']
it 'should fail if not logged' do
Scripts.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]
2020-05-13 07:51:51 +02:00
(ticketFromUser['ticketNumber']).should.equal(ticket['ticket_number'].to_s)
(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'])
2020-05-13 07:51:51 +02:00
(ticketFromUser['date'].to_i).should.equal(ticket['date'].to_i)
(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([])
end
end