Merge pull request #248 from guillegiu/master

Add  test of feature #101
This commit is contained in:
Ivan Diaz 2018-07-17 01:16:04 -03:00 committed by GitHub
commit 92012d639b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 61 additions and 9 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

@ -10,6 +10,6 @@ describe '/staff/get-new-tickets' do
})
(result['status']).should.equal('success')
(result['data'].size).should.equal(7)
(result['data'].size).should.equal(9)
end
end
end

View File

@ -19,7 +19,7 @@ describe'system/disable-user-system' do
numberOftickets= $database.query("SELECT * FROM ticket WHERE author_id IS NULL AND author_email IS NOT NULL AND author_name IS NOT NULL")
(numberOftickets.num_rows).should.equal(36)
(numberOftickets.num_rows).should.equal(38)
request('/user/logout')
@ -92,7 +92,7 @@ describe'system/disable-user-system' do
numberOftickets= $database.query("SELECT * FROM ticket WHERE author_email IS NULL AND author_name IS NULL AND author_id IS NOT NULL" )
(numberOftickets.num_rows).should.equal(37)
(numberOftickets.num_rows).should.equal(39)
end

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,28 @@ 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')
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,28 @@ 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')
lastLog = $database.getLastRow('log')
(lastLog['type']).should.equal('RE_OPEN')
end
end

View File

@ -36,7 +36,7 @@ describe '/user/get-users' do
})
(result['status']).should.equal('success')
(result['data']['users'].size).should.equal(3)
(result['data']['users'].size).should.equal(5)
end
it 'should get users with order by tickets and asc' do