test of feature #101

This commit is contained in:
Guillermo 2018-07-12 02:08:37 -03:00
parent 2c1e5f1a61
commit 787bd9a42b
3 changed files with 58 additions and 4 deletions

View File

@ -69,6 +69,16 @@ class Scripts
result['data']
end
def self.closeTicket(ticketNumber)
result = request('/ticket/close', {
ticketNumber:ticketNumber,
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
result['data']
end
def self.createAPIKey(name)
request('/system/add-api-key', {
csrf_userid: $csrf_userid,

View File

@ -2,8 +2,6 @@ describe '/ticket/close' do
request('/user/logout')
Scripts.login($staff[:email], $staff[:password], true)
#TODO: DO THINGS
it 'should close a ticket if everything is okey' do
ticket = $database.getRow('ticket', 1 , 'id')
@ -21,5 +19,29 @@ describe '/ticket/close' do
lastLog = $database.getLastRow('log')
(lastLog['type']).should.equal('CLOSE')
request('/user/logout')
Scripts.createUser('closer@os4.com','closer','Closer')
Scripts.login('closer@os4.com','closer')
Scripts.createTicket('tickettoclose')
ticket = $database.getRow('ticket', 'tickettoclose', 'title')
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')
(ticket['unread']).should.equal('1')
lastLog = $database.getLastRow('log')
(lastLog['type']).should.equal('CLOSE')
end
end

View File

@ -2,8 +2,6 @@ describe '/ticket/re-open' do
request('/user/logout')
Scripts.login($staff[:email], $staff[:password], true)
#TODO: DO THINGS
it 'should re open a ticket if everything is okey' do
ticket = $database.getRow('ticket', 1 , 'id')
@ -21,5 +19,29 @@ describe '/ticket/re-open' do
lastLog = $database.getLastRow('log')
(lastLog['type']).should.equal('RE_OPEN')
request('/user/logout')
Scripts.createUser('reopener@os4.com','reopener','Reopener')
Scripts.login('reopener@os4.com','reopener')
Scripts.createTicket('tickettoreopen')
ticket = $database.getRow('ticket', 'tickettoreopen', 'title')
Scripts.closeTicket(ticket['ticketNumber'])
result = request('/ticket/re-open', {
ticketNumber: ticket['ticket_number'],
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
(result['status']).should.equal('success')
ticket = $database.getRow('ticket', 'tickettoreopen', 'title')
(ticket['closed']).should.equal('0')
(ticket['unread']).should.equal('1')
lastLog = $database.getLastRow('log')
(lastLog['type']).should.equal('RE_OPEN')
end
end